C# Lists item at location
I'm working on C# Lists and i need an item at list location x how do i do it? t开发者_开发技巧hanks for helping me
List<int> numbers = new List<int> {4,5,6};
var atPos2 = numbers[2];
atPos2
will contain the number 6.
Just use the indexer to get the item in that index:
var myItem = myList[myIndex];
You could also take a look at the ElementAt extension method...
Use or create a (generic)collection that implements IList
精彩评论