本文整理汇总了C#中System.Array.GetRawArrayData方法的典型用法代码示例。如果您正苦于以下问题:C# Array.GetRawArrayData方法的具体用法?C# Array.GetRawArrayData怎么用?C# Array.GetRawArrayData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Array
的用法示例。
在下文中一共展示了Array.GetRawArrayData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlockCopy
public static unsafe void BlockCopy(Array src, int srcOffset,
Array dst, int dstOffset,
int count)
{
if (src == null)
throw new ArgumentNullException(nameof(src));
if (dst == null)
throw new ArgumentNullException(nameof(dst));
RuntimeImports.RhCorElementTypeInfo srcCorElementTypeInfo = src.ElementEEType.CorElementTypeInfo;
nuint uSrcLen = ((nuint)src.Length) << srcCorElementTypeInfo.Log2OfSize;
nuint uDstLen = uSrcLen;
if (!srcCorElementTypeInfo.IsPrimitive)
throw new ArgumentException(SR.Arg_MustBePrimArray, nameof(src));
if (src != dst)
{
RuntimeImports.RhCorElementTypeInfo dstCorElementTypeInfo = dst.ElementEEType.CorElementTypeInfo;
if (!dstCorElementTypeInfo.IsPrimitive)
throw new ArgumentException(SR.Arg_MustBePrimArray, nameof(dst));
uDstLen = ((nuint)dst.Length) << dstCorElementTypeInfo.Log2OfSize;
}
if (srcOffset < 0)
throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_MustBeNonNegInt32, nameof(srcOffset));
if (dstOffset < 0)
throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_MustBeNonNegInt32, nameof(dstOffset));
if (count < 0)
throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_MustBeNonNegInt32, nameof(count));
nuint uCount = (nuint)count;
if (uSrcLen < ((nuint)srcOffset) + uCount)
throw new ArgumentException(SR.Argument_InvalidOffLen);
if (uDstLen < ((nuint)dstOffset) + uCount)
throw new ArgumentException(SR.Argument_InvalidOffLen);
if (uCount == 0)
return;
fixed (byte* pSrc = &src.GetRawArrayData(), pDst = &dst.GetRawArrayData())
{
Buffer.Memmove(pDst + dstOffset, pSrc + srcOffset, uCount);
}
}
示例2: SetByte
public static unsafe void SetByte(Array array, int index, byte value)
{
// Is the array present?
if (array == null)
throw new ArgumentNullException(nameof(array));
// Is it of primitive types?
if (!array.ElementEEType.IsPrimitive)
throw new ArgumentException(SR.Arg_MustBePrimArray, nameof(array));
// Is the index in valid range of the array?
if (index < 0 || index >= _ByteLength(array))
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref array.GetRawArrayData(), index) = value;
}
示例3: GetByte
public static unsafe byte GetByte(Array array, int index)
{
// Is the array present?
if (array == null)
throw new ArgumentNullException("array");
// Is it of primitive types?
if (!array.ElementEEType.IsPrimitive)
throw new ArgumentException(SR.Arg_MustBePrimArray, "array");
// Is the index in valid range of the array?
if (index < 0 || index >= _ByteLength(array))
throw new ArgumentOutOfRangeException("index");
return Unsafe.Add(ref array.GetRawArrayData(), index);
}