C# 如何获取ObservableCollection中指定索引处的最后一个元素/元素
一,。如何获取ObservableCollection中的最后一个元素 二,。如何在ObservableCollection中的指定索引处获取元素 在java中,它只是1.collection.getcollection.size-1;2.collection.getindex;如何在c中获得它 collectionName.Last将返回集合中的最后一个元素。确保您有对System.Linq的引用 collectionName[4]将返回集合中的第5个元素集合是基于零的 collectionName.Last将返回集合中的最后一个元素。确保您有对System.Linq的引用 collectionName[4]将返回集合中的第5个元素集合是基于零的 收藏: 与系统。Linq 收藏: 与系统。LinqC# 如何获取ObservableCollection中指定索引处的最后一个元素/元素,c#,collections,C#,Collections,一,。如何获取ObservableCollection中的最后一个元素 二,。如何在ObservableCollection中的指定索引处获取元素 在java中,它只是1.collection.getcollection.size-1;2.collection.getindex;如何在c中获得它 collectionName.Last将返回集合中的最后一个元素。确保您有对System.Linq的引用 collectionName[4]将返回集合中的第5个元素集合是基于零的 collectionN
1.集合[collection.count-1]2。集合[index]collection.Last和collection.ElementAtcollection.Count-11。集合[collection.count-1]2。集合[index]collection.Last和collection.ElementAtcollection.Count-1
ObservableCollection<string> collection = new ObservableCollection<string> {"one", "two", "three", "four"};
collection[2]; //returns three
collection[collection.Count - 1]; //returns four
collection.Last(); //returns four
collection.ElementAt(collection.Count - 1); //returns four
collection.ElementAt(1); //returns two