//HIERO: void ICollection <KeyValuePair <EK, EV> > .CopyTo(KeyValuePair <EK, EV>[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } if (arrayIndex < 0 || arrayIndex > array.Length) { throw new IndexOutOfRangeException(); } int i = 0; int end = array.Length - arrayIndex; var buffer = new KeyValuePair <EK, EV> [end]; using (var it = ((IEnumerable <KeyValuePair <EK, EV> >) this).GetEnumerator()) while (it.MoveNext()) { if (i == end) { throw new ArgumentException(); } buffer[i++] = it.Current; } buffer.CopyTo(array, arrayIndex); }
public void CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex) { KeyValuePair <TKey, TValue>[] keyValuePairArray = new KeyValuePair <TKey, TValue> [Count]; int count = 0; foreach (KeyValuePair <TKey, TValue> keyValuePair in this) // # Using GetEnumerator() implementation of 'this' { keyValuePairArray[count++] = keyValuePair; } keyValuePairArray.CopyTo(array, arrayIndex); }