C# 中 方法 ElementAt(下标) 在 List 的使用

 
 1 public class ListElementAtDemo : MonoBehaviour {
 2 
 3     List<string> list = new List<string>();
 4 
 5     void Awake()
 6     {
 7         list.Add("aaaaaa");
 8         list.Add("bbbbbb");
 9         list.Add("cccccc");
10         list.Add("dddddd");
11     }
12 
13     void Start ()
14     { 
15         Debug.Log(list.ElementAt(0));       
16         Debug.Log(list[0]);
17     }
18     
19 }
两种的打印结果都是 aaaaaa   。  但是ElementAt 这个方法,需要导入 using System.Linq;  这个命名空间

打印结果是  aaaaaa。其实和 

posted @ 2020-12-13 18:07  赛涛科技  阅读(1734)  评论(0)    收藏  举报