本文整理汇总了C#中Array.GetRawSzArrayData方法的典型用法代码示例。如果您正苦于以下问题:C# Array.GetRawSzArrayData方法的具体用法?C# Array.GetRawSzArrayData怎么用?C# Array.GetRawSzArrayData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array.GetRawSzArrayData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StelemRef
static public unsafe void StelemRef(Array array, int index, object obj)
{
// This is supported only on arrays
Debug.Assert(array.EEType->IsArray, "first argument must be an array");
if (index >= array.Length)
{
throw array.EEType->GetClasslibException(ExceptionIDs.IndexOutOfRange);
}
if (obj != null)
{
EEType* arrayElemType = array.EEType->RelatedParameterType;
if (!CastCache.AreTypesAssignableInternal(obj.EEType, arrayElemType, AssignmentVariation.BoxedSource))
{
// If object type implements ICastable then there's one more way to check whether it implements
// the interface.
if (!obj.EEType->IsICastable || !IsInstanceOfInterfaceViaICastable(obj, arrayElemType))
{
// Throw the array type mismatch exception defined by the classlib, using the input array's
// EEType* to find the correct classlib.
throw array.EEType->GetClasslibException(ExceptionIDs.ArrayTypeMismatch);
}
}
// Both bounds and type check are ok.
// Call write barrier directly. Assigning object reference would call slower checked write barrier.
ref Object rawData = ref Unsafe.As<byte, Object>(ref array.GetRawSzArrayData());
InternalCalls.RhpAssignRef(ref Unsafe.Add(ref rawData, index), obj);
}
else
{
// Storing null does not require write barrier
ref IntPtr rawData = ref Unsafe.As<byte, IntPtr>(ref array.GetRawSzArrayData());
Unsafe.Add(ref rawData, index) = default(IntPtr);
}