public static ReadOnlySpan <T> DangerousCreate(object obj, ref T objectData, int length) { Pinnable <T> pinnable = Unsafe.As <Pinnable <T> >(obj); IntPtr byteOffset = Unsafe.ByteOffset <T>(ref pinnable.Data, ref objectData); return(new ReadOnlySpan <T>(pinnable, byteOffset, length)); }
internal ReadOnlySpan(Pinnable <T> pinnable, IntPtr byteOffset, int length) { Debug.Assert(length >= 0); _length = length; _pinnable = pinnable; _byteOffset = byteOffset; }
public static Span <T> DangerousCreate(object obj, ref T objectData, int length) { if (obj == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj); } if (length < 0) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); } Pinnable <T> pinnable = Unsafe.As <Pinnable <T> >(obj); IntPtr byteOffset = Unsafe.ByteOffset <T>(ref pinnable.Data, ref objectData); return(new Span <T>(pinnable, byteOffset, length)); }