Last active
December 11, 2015 03:58
-
-
Save corruptmem/4541346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var lists = new[] { new[] { 1, 2, 3 }.ToList(), new[] { 4, 5, 6 }.ToList() }; | |
var enumerators = lists.Select(x => x.GetEnumerator()).ToList(); | |
var enumeratorEnumerator = enumerators.GetEnumerator(); | |
while(enumeratorEnumerator.MoveNext()) // ******* | |
{ | |
((IEnumerator<int>)enumeratorEnumerator.Current).MoveNext(); // ****** | |
} | |
var values = enumerators.Select(x => x.Current).ToArray(); | |
Console.WriteLine("{0}, {1}", values[0], values[1]); // Writes 0, 0 (as in, default(int), default(int)) | |
Console.ReadKey(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var lists = new[] { new[] { 1, 2, 3 }.ToList(), new[] { 4, 5, 6 }.ToList() }; | |
var enumerators = lists.Select(x => x.GetEnumerator()).ToArray(); | |
for (int i = 0; i < enumerators.Length; i++ ) // ******* | |
{ | |
enumerators[i].MoveNext(); // ****** | |
} | |
var values = enumerators.Select(x => x.Current).ToArray(); | |
Console.WriteLine("{0}, {1}", values[0], values[1]); // Writes 1, 4 | |
Console.ReadKey(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var lists = new[] { new[] { 1, 2, 3 }.ToList(), new[] { 4, 5, 6 }.ToList() }; | |
var enumerators = lists.Select(x => x.GetEnumerator()).ToArray(); | |
foreach (var enumerator in enumerators) // ******* | |
{ | |
enumerator.MoveNext(); // ****** | |
} | |
var values = enumerators.Select(x => x.Current).ToArray(); | |
Console.WriteLine("{0}, {1}", values[0], values[1]); // Writes 0, 0 (as in, default(int), default(int)) | |
Console.ReadKey(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var lists = new[] { new[] { 1, 2, 3 }.ToList(), new[] { 4, 5, 6 }.ToList() }; | |
var enumerators = lists.Select(x => x.GetEnumerator()).ToArray(); | |
foreach (var enumerator in enumerators) // ******* | |
{ | |
enumerator.MoveNext(); // ****** | |
Console.WriteLine(enumerator.Current); // writes 1, then 4 | |
} | |
var values = enumerators.Select(x => x.Current).ToArray(); | |
Console.WriteLine("{0}, {1}", values[0], values[1]); // Writes 0, 0 (as in, default(int), default(int)) | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment