相关疑难解决方法(0)

通过C#对ObservableCollection <string>进行排序

我在下面ObservableCollection<string>.我需要进行排序按字母顺序这一点.

private ObservableCollection<string> _animals = new ObservableCollection<string>
{
    "Cat", "Dog", "Bear", "Lion", "Mouse",
    "Horse", "Rat", "Elephant", "Kangaroo", "Lizard", 
    "Snake", "Frog", "Fish", "Butterfly", "Human", 
    "Cow", "Bumble Bee"
};
Run Code Online (Sandbox Code Playgroud)

我试过了_animals.OrderByDescending.但我不知道如何正确使用它.

_animals.OrderByDescending(a => a.<what_is_here_?>);
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

c# sorting observablecollection

46
推荐指数
6
解决办法
11万
查看次数

我怎样才能对ObservableCollection进行排序?

我试过了:

Persons = from i in Persons orderby i.Age select i;
Run Code Online (Sandbox Code Playgroud)

但我无法将Linqs转换System.Linq.IOrderedEnumerableObservableCollection<Person>.

c#

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×2

observablecollection ×1

sorting ×1