public void CopyTo(Array dest, int index)
{
if (dest == null)
{
throw new ArgumentNullException(nameof(dest));
}
if (dest.Rank != 1)
{
throw new ArgumentException(SR.Arg_MultiRank, nameof(dest));
}
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum);
}
if (dest.Length - index < Count)
{
throw new ArgumentException(SR.Arg_InsufficientSpace);
}
int n = Count;
if (_all == null)
{
String[] all = new String[n];
for (int i = 0; i < n; i++)
{
all[i] = Get(i);
dest.SetValue(all[i], i + index);
}
_all = all; // wait until end of loop to set _all reference in case Get throws
}
else
{
for (int i = 0; i < n; i++)
{
dest.SetValue(_all[i], i + index);
}
}
}