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

◆ GetSubArray< T >()

static T[] System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray< T > ( T[] array,
Range range )
inlinestatic

Definition at line 256 of file RuntimeHelpers.cs.

257 {
258 if (array == null)
259 {
260 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
261 }
262 var (elementOffset, num) = range.GetOffsetAndLength(array.Length);
263 T[] array2;
264 if (typeof(T).IsValueType || typeof(T[]) == array.GetType())
265 {
266 if (num == 0)
267 {
268 return Array.Empty<T>();
269 }
270 array2 = new T[num];
271 }
272 else
273 {
274 array2 = Unsafe.As<T[]>(Array.CreateInstance(array.GetType().GetElementType(), num));
275 }
277 return array2;
278 }
static unsafe ref byte GetArrayDataReference(Array array)

References System.array, System.Array.CreateInstance(), System.Runtime.Serialization.Dictionary, System.Runtime.InteropServices.MemoryMarshal.GetArrayDataReference(), System.Buffer.Memmove(), and System.ThrowHelper.ThrowArgumentNullException().