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

◆ CreateInstance() [4/6]

static unsafe Array System.Array.CreateInstance ( Type elementType,
int[] lengths,
int[] lowerBounds )
inlinestatic

Definition at line 578 of file Array.cs.

579 {
580 if (elementType == null)
581 {
582 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType);
583 }
584 if (lengths == null)
585 {
586 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths);
587 }
588 if (lowerBounds == null)
589 {
590 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lowerBounds);
591 }
592 if (lengths.Length != lowerBounds.Length)
593 {
594 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RanksAndBounds);
595 }
596 if (lengths.Length == 0)
597 {
598 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank);
599 }
600 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
601 if (runtimeType == null)
602 {
603 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType);
604 }
605 for (int i = 0; i < lengths.Length; i++)
606 {
607 if (lengths[i] < 0)
608 {
609 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
610 }
611 }
612 fixed (int* pLengths = &lengths[0])
613 {
614 fixed (int* pLowerBounds = &lowerBounds[0])
615 {
616 return InternalCreate((void*)runtimeType.TypeHandle.Value, lengths.Length, pLengths, pLowerBounds);
617 }
618 }
619 }
static unsafe Array InternalCreate(void *elementType, int rank, int *pLengths, int *pLowerBounds)

References System.elementType, System.Array.InternalCreate(), System.lengths, System.lowerBounds, System.ThrowHelper.ThrowArgumentException(), System.ThrowHelper.ThrowArgumentNullException(), and System.ThrowHelper.ThrowArgumentOutOfRangeException().