public static T[,] Ctor(int length1, int length2) { if ((length1 < 0) || (length2 < 0)) { throw new OverflowException(); } MDArrayRank2 <T> newArray = Unsafe.As <MDArrayRank2 <T> >(RuntimeImports.RhNewArray(typeof(T[, ]).TypeHandle.ToEETypePtr(), checked (length1 * length2))); newArray._upperBound1 = length1; newArray._upperBound2 = length2; return(Unsafe.As <T[, ]>(newArray)); }
private static ref T InternalAddress(T[,] array, int index1, int index2) { MDArrayRank2 <T> mdArrayObj = Unsafe.As <MDArrayRank2 <T> >(array); if ((index1 < 0) || (index1 >= mdArrayObj._upperBound1)) { throw new IndexOutOfRangeException(); } if ((index2 < 0) || (index2 >= mdArrayObj._upperBound2)) { throw new IndexOutOfRangeException(); } int index = (index1 * mdArrayObj._upperBound2) + index2; return(ref Unsafe.Add(ref mdArrayObj._data, index)); }
private static ByReference <T> InternalAddress(T[,] array, int index1, int index2) { MDArrayRank2 <T> mdArrayObj = Unsafe.As <MDArrayRank2 <T> >(array); if ((index1 < 0) || (index1 >= mdArrayObj._upperBound1)) { throw new IndexOutOfRangeException(); } if ((index2 < 0) || (index2 >= mdArrayObj._upperBound2)) { throw new IndexOutOfRangeException(); } int index = (index1 * mdArrayObj._upperBound2) + index2; int offset = ByReference <T> .SizeOfT() * index + 2 * 8; ByReference <int> _upperBound1Ref = ByReference <int> .FromRef(ref mdArrayObj._upperBound1); return(ByReference <int> .Cast <T>(ByReference <int> .AddRaw(_upperBound1Ref, offset))); }