LINQ - selecting second item in IEnumerable

后端 未结 4 628
执念已碎
执念已碎 2020-12-05 17:11

I have

string[] pkgratio= \"1:2:6\".Split(\':\');

var items = pkgratio.OrderByDescending(x => x);

I want to select

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 17:44

    pkgratio.ElementAt(1); for your scenario.

    However, your method is only applicable if you were using some data that implemented IQueryable or you needed to take a range of items starting at a specific index eg:

    pkgratio.Skip(5).Take(10);

提交回复
热议问题