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

◆ CreateInstance() [2/6]

static unsafe Array System.Array.CreateInstance ( Type elementType,
int length1,
int length2 )
inlinestatic

Definition at line 491 of file Array.cs.

492 {
493 if ((object)elementType == null)
494 {
495 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType);
496 }
497 if (length1 < 0)
498 {
499 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
500 }
501 if (length2 < 0)
502 {
503 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
504 }
505 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
506 if (runtimeType == null)
507 {
508 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType);
509 }
510 int* ptr = stackalloc int[2];
511 *ptr = length1;
512 ptr[1] = length2;
513 return InternalCreate((void*)runtimeType.TypeHandle.Value, 2, ptr, null);
514 }
static unsafe Array InternalCreate(void *elementType, int rank, int *pLengths, int *pLowerBounds)

References System.elementType, System.Array.InternalCreate(), System.length1, System.length2, System.ThrowHelper.ThrowArgumentException(), System.ThrowHelper.ThrowArgumentNullException(), and System.ThrowHelper.ThrowArgumentOutOfRangeException().