0
List<String> hello = new List<String>();
hello.Add("red");
hello.Add("blue");
如何使用索引搜索此列表得到"red"
这将是0
?我尝试了很多不同的方法,但都失败了。使用索引在List中查找值?
List<String> hello = new List<String>();
hello.Add("red");
hello.Add("blue");
如何使用索引搜索此列表得到"red"
这将是0
?我尝试了很多不同的方法,但都失败了。使用索引在List中查找值?
如果我明白你的问题,该.FindIndex Method
List<String> hello = new List<String>();
hello.Add("red");
hello.Add("blue");
var index = hello.FindIndex(c => c == "red");
var word = hello[index]; //<-- get the word
var word = hello.ElementAt(0);
更好地直接使用列表索引。更习惯和更快。 – usr 2013-02-14 10:02:32