Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取ObservableCollection中指定索引处的最后一个元素/元素_C#_Collections - Fatal编程技术网

C# 如何获取ObservableCollection中指定索引处的最后一个元素/元素

C# 如何获取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

一,。如何获取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

收藏:

与系统。Linq


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