.net2.0中改变数组大小
.net1.x中
private Array Redim(Array oldArr, int nNewSize)
{
Type type = oldArr.GetType().GetElementType();
Array newArr = Array.CreateInstance(type, nNewSize);
if (object.Equals(null, oldArr))
{
return newArr;
}
Array.Copy(oldArr, 0, newArr, 0, Math.Min(oldArr.Length, nNewSize));
return newArr;
}
.net2.0中{
Type type = oldArr.GetType().GetElementType();
Array newArr = Array.CreateInstance(type, nNewSize);
if (object.Equals(null, oldArr))
{
return newArr;
}
Array.Copy(oldArr, 0, newArr, 0, Math.Min(oldArr.Length, nNewSize));
return newArr;
}
Array.Resize<byte>(ref arrResult, nTotalCount);