Mercurial > pub > bltoolkit
comparison Source/Linq/Extensions.cs @ 0:f990fcb411a9
Копия текущей версии из github
| author | cin |
|---|---|
| date | Thu, 27 Mar 2014 21:46:09 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f990fcb411a9 |
|---|---|
| 1 using System; | |
| 2 using System.Collections.Generic; | |
| 3 | |
| 4 using JetBrains.Annotations; | |
| 5 | |
| 6 namespace BLToolkit.Linq | |
| 7 { | |
| 8 public static class Extensions | |
| 9 { | |
| 10 public static IEnumerable<TResult> Zip<TFirst,TSecond,TResult>( | |
| 11 [NotNull] this IEnumerable<TFirst> first, | |
| 12 [NotNull] IEnumerable<TSecond> second, | |
| 13 [NotNull] Func<TFirst,TSecond,TResult> resultSelector) | |
| 14 { | |
| 15 if (first == null) throw new ArgumentNullException("first"); | |
| 16 if (second == null) throw new ArgumentNullException("second"); | |
| 17 if (resultSelector == null) throw new ArgumentNullException("resultSelector"); | |
| 18 | |
| 19 using (var e1 = first.GetEnumerator()) | |
| 20 using (var e2 = second.GetEnumerator()) | |
| 21 while (e1.MoveNext() && e2.MoveNext()) | |
| 22 yield return resultSelector(e1.Current, e2.Current); | |
| 23 } | |
| 24 } | |
| 25 } |
