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。其實和 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM