把开发过程中常用的内容备份一次,下面代码是关于C# 通过指针实现的fastcopy的代码。
using System;
class Test
{
static unsafe void Copy(byte[] src, int srcIndex,
byte[] dst, int dstIndex, int count)
{
if (src == null || srcIndex < 0 ||
dst == null || dstIndex < 0 || count < 0)
{
throw new ArgumentException();
}
int srcLen = src.Length;
int dstLen = dst.Length;
if (srcLen - srcIndex < count ||
dstLen - dstIndex < count)
{
throw new ArgumentException();
}
{
for (int n = 0; n < count / 4; n++)
{
pd += 4;
ps += 4;
}
for (int n = 0; n < count % 4; n++)
{
pd++;
ps++;
}
}
}
static void Main(string[] args)
{