0
List<String> hello = new List<String>();

hello.Add("red");
hello.Add("blue");

インデックスを使用してこのリストを検索して、どれが になるかを取得"red"するにはどうすればよい0ですか? いろいろな方法を試しましたが、だめでした。

4

1 に答える 1

2

あなたの質問を理解できれば、.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 

そして最後に使用.ElementAt Method

var word = hello.ElementAt(0);
于 2013-02-13T22:52:57.717 に答える