开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜