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

◆ CopyTo() [1/2]

void ICollection. System.Collections.ObjectModel.ReadOnlyCollection< T >.CopyTo ( Array array,
int index )
inlineprivateinherited

Implements System.Collections.ICollection.

Definition at line 125 of file ReadOnlyCollection.cs.

126 {
127 if (array == null)
128 {
129 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
130 }
131 if (array.Rank != 1)
132 {
133 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
134 }
135 if (array.GetLowerBound(0) != 0)
136 {
137 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NonZeroLowerBound);
138 }
139 if (index < 0)
140 {
141 ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException();
142 }
143 if (array.Length - index < Count)
144 {
145 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
146 }
147 if (array is T[] array2)
148 {
149 list.CopyTo(array2, index);
150 return;
151 }
152 Type elementType = array.GetType().GetElementType();
154 if (!elementType.IsAssignableFrom(typeFromHandle) && !typeFromHandle.IsAssignableFrom(elementType))
155 {
156 ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
157 }
158 object[] array3 = array as object[];
159 if (array3 == null)
160 {
161 ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
162 }
163 int count = list.Count;
164 try
165 {
166 for (int i = 0; i < count; i++)
167 {
168 array3[index++] = list[i];
169 }
170 }
171 catch (ArrayTypeMismatchException)
172 {
173 ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType();
174 }
175 }

References System.array, System.count, System.Collections.ObjectModel.ReadOnlyCollection< T >.Count, System.elementType, System.Type.GetType(), System.index, System.Collections.ObjectModel.ReadOnlyCollection< T >.list, System.ThrowHelper.ThrowArgumentException(), System.ThrowHelper.ThrowArgumentException_Argument_InvalidArrayType(), System.ThrowHelper.ThrowArgumentNullException(), and System.ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException().