开发者

C# Lists item at location

开发者 https://www.devze.com 2023-02-25 04:11 出处:网络
I\'m working on C# Lists and i need an item at list location x how do i do it? t开发者_开发技巧hanks for helping meList<int> numbers = new List<int> {4,5,6};

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

0

精彩评论

暂无评论...
验证码 换一张
取 消