Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ AsSpan< T >() [7/10]

static Span< T > System.MemoryExtensions.AsSpan< T > ( this T?[] array,
Index startIndex )
inlinestatic

Definition at line 323 of file MemoryExtensions.cs.

324 {
325 if (array == null)
326 {
327 if (!startIndex.Equals(Index.Start))
328 {
329 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
330 }
331 return default(Span<T>);
332 }
333 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
334 {
335 ThrowHelper.ThrowArrayTypeMismatchException();
336 }
337 int offset = startIndex.GetOffset(array.Length);
338 if ((uint)offset > (uint)array.Length)
339 {
340 ThrowHelper.ThrowArgumentOutOfRangeException();
341 }
342 return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)offset), array.Length - offset);
343 }
static unsafe ref byte GetArrayDataReference(Array array)

References System.array, System.Runtime.InteropServices.MemoryMarshal.GetArrayDataReference(), System.offset, System.Index.Start, System.startIndex, System.ThrowHelper.ThrowArgumentNullException(), System.ThrowHelper.ThrowArgumentOutOfRangeException(), and System.ThrowHelper.ThrowArrayTypeMismatchException().