Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

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

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

Definition at line 346 of file MemoryExtensions.cs.

347 {
348 if (array == null)
349 {
350 Index start = range.Start;
351 Index end = range.End;
352 if (!start.Equals(Index.Start) || !end.Equals(Index.Start))
353 {
354 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
355 }
356 return default(Span<T>);
357 }
358 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
359 {
360 ThrowHelper.ThrowArrayTypeMismatchException();
361 }
362 var (num, length) = range.GetOffsetAndLength(array.Length);
363 return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)num), length);
364 }
static unsafe ref byte GetArrayDataReference(Array array)

References System.array, System.Index.Equals(), System.Runtime.InteropServices.MemoryMarshal.GetArrayDataReference(), System.length, System.start, System.Index.Start, System.ThrowHelper.ThrowArgumentNullException(), and System.ThrowHelper.ThrowArrayTypeMismatchException().