Skip to content

Commit

Permalink
Fix CopyInto to allow specification of the destination index
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhowie committed Mar 22, 2013
1 parent a076f5a commit 832ad80
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Cdh.Toolkit.Extensions/Enumerable/Extensions.cs
Expand Up @@ -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)
Expand Down

0 comments on commit 832ad80

Please sign in to comment.