feature: Extension method for copying an enumerable into an array

This commit is contained in:
Chris Cameron
2018-04-11 13:05:13 -04:00
parent 990f4e0f82
commit 416bf6414e

View File

@@ -578,6 +578,23 @@ namespace ICD.Common.Utils.Extensions
return extends.Where(i => !comparer.Equals(item, i));
}
/// <summary>
/// Copies all the elements of the current one-dimensional array to the specified one-dimensional array
/// starting at the specified destination array index. The index is specified as a 32-bit integer.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="extends"></param>
/// <param name="array"></param>
/// <param name="index"></param>
public static void CopyTo<T>(this IEnumerable<T> extends, T[] array, int index)
{
if (extends == null)
throw new ArgumentNullException("extends");
ICollection<T> collection = extends as ICollection<T> ?? extends.ToArray();
collection.CopyTo(array, index);
}
/// <summary>
/// Returns the sequence as a IcdHashSet.
/// </summary>