1.如何獲取ObservableCollection
中的最後一個元素?如何獲取ObservableCollection中指定索引處的最後一個元素/元素
2.如何在ObservableCollection
的指定索引處獲取元素?
在java中它只是 collection.get(collection.size()-1);
2.collection.get(index);
如何獲得在C#?
1.如何獲取ObservableCollection
中的最後一個元素?如何獲取ObservableCollection中指定索引處的最後一個元素/元素
2.如何在ObservableCollection
的指定索引處獲取元素?
在java中它只是 collection.get(collection.size()-1);
2.collection.get(index);
如何獲得在C#?
collectionName.Last()
將返回集合中的最後一個元素。確保你有一個參考System.Linq
collectionName[4]
將返回集合中的第5個元素(集合是從零開始的)。
收藏:
ObservableCollection<string> collection = new ObservableCollection<string> {"one", "two", "three", "four"};
沒有System.Linq的;
collection[2]; //returns three
collection[collection.Count - 1]; //returns four
隨着System.Linq的;
collection.Last(); //returns four
collection.ElementAt(collection.Count - 1); //returns four
collection.ElementAt(1); //returns two
1.集合[collection.count-1] 2.集合[指數] – user2930100
'collection.Last()'和'collection.ElementAt(collection.Count() - 1)' –