Skip to content
Browse files

Fix CopyInto to allow specification of the destination index

  • Loading branch information...
1 parent a076f5a commit 832ad80edd494f0f652680ab15ba46d819b23de8 @cdhowie committed
Showing with 7 additions and 4 deletions.
  1. +7 −4 Cdh.Toolkit.Extensions/Enumerable/Extensions.cs
View
11 Cdh.Toolkit.Extensions/Enumerable/Extensions.cs
@@ -55,16 +55,19 @@ public static void Walk<T>(this IEnumerable<T> self)
using (IEnumerator<T> walker = self.GetEnumerator())
while (walker.MoveNext()) ;
}
-
+
public static void CopyInto<T>(this IEnumerable<T> self, IList<T> list)
{
+ CopyInto<T>(self, list, 0);
+ }
+
+ public static void CopyInto<T>(this IEnumerable<T> self, IList<T> list, int index)
+ {
Check.ArgumentIsNotNull(self, "self");
Check.ArgumentIsNotNull(list, "list");
- int i = 0;
-
foreach (T item in self)
- list[i++] = item;
+ list[index++] = item;
}
public static IEnumerable<T> Delimit<T>(this IEnumerable<T> self, T delimiter)

0 comments on commit 832ad80

Please sign in to comment.
Something went wrong with that request. Please try again.