Nar*_*uto 1 .net c# containers iterator list
我有一个包含字符串集的列表,我想基于索引获取列表中的数据,而不使用迭代器..是否有任何函数,如get()或getat()使用哪种方法我们可以获取?
myList [index]是要走的路
List<string> myList = new List<string>();
myList.Add("string 1");
myList.Add("String 2");
Console.WriteLine(myList[0]); // string 1
Console.WriteLine(myList[1]); // String 2
Run Code Online (Sandbox Code Playgroud)
List<string> myList = new List<string();
//add some elements to the list
//then get the third element
string thirdElement = myList[2];
Run Code Online (Sandbox Code Playgroud)