Last active
July 29, 2016 20:36
-
-
Save gowon/c1ce304c9c3edf54756cee9d49f1931e to your computer and use it in GitHub Desktop.
Getting an index on an enumeration.
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
// http://stackoverflow.com/a/77542 | |
System.Collections.IEnumerable collection = Enumerable.Range(100, 10); | |
foreach (var o in collection.OfType<object>().Select((x, i) => new {x, i})) | |
{ | |
Console.WriteLine("{0} {1}", o.i, o.x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment