mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
feature: Extension method for copying an enumerable into an array
This commit is contained in:
@@ -578,6 +578,23 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
return extends.Where(i => !comparer.Equals(item, i));
|
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>
|
/// <summary>
|
||||||
/// Returns the sequence as a IcdHashSet.
|
/// Returns the sequence as a IcdHashSet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user