mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feature: Extension method for copying an enumerable into an array
This commit is contained in:
parent
990f4e0f82
commit
416bf6414e
1 changed files with 17 additions and 0 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue