本文整理汇总了C#中Collection.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.OrderByDescending方法的具体用法?C# Collection.OrderByDescending怎么用?C# Collection.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.OrderByDescending方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
ICollection<Student> students = new Collection<Student>()
{
new Student("Samson", "Weaver", "QQK01GRD3E"),
new Student("Oren", "Alston", "SEC56MNQ9L"),
new Student("Hamish", "Spears", "RXL23WN5FL"),
new Student("Chester", "Luna", "FQJ10XOGMR"),
new Student("Tyrone", "Burris", "EHG52ZP0PR"),
new Student("Palmer", "Reed", "ITF39VMIGN"),
new Student("Fritz", "Weber", "LFZ54BJ4BR"),
new Student("Nero", "Romero", "VVG90AH2PF"),
new Student("Giacomo", "Stein", "OVH15YV4MO"),
new Student("Merrill", "Baxter", "PZV0KEU0GS")
};
var sortedStudents = students.OrderBy(s => s.FacultyNumber);
ICollection<Worker> workers = new Collection<Worker>()
{
new Worker("Urielle", "Dorsey", 96.56m, 4),
new Worker("Haley", "Keller", 79.51m, 4),
new Worker("Zenia", "Pena", 14.76m, 3),
new Worker("MacKensie", "Bean", 42.71m, 5),
new Worker("Rhea", "Hood", 9.33m, 3),
new Worker("Caryn", "Figueroa", 74.21m, 8),
new Worker("Charde", "Peterson", 89.30m, 8),
new Worker("Sylvia", "Gonzalez", 65.00m, 6),
new Worker("Catherine", "Bishop", 90.58m, 7),
new Worker("Ramona", "King", 18.02m, 8),
};
var sortedWorkers = workers.OrderByDescending(w => w.MoneyPerHour());
// check data validity here
foreach (var worker in workers)
{
//Console.WriteLine(worker);
}
var allHumans = new List<Human>(students.Count + workers.Count);
allHumans.AddRange(students);
allHumans.AddRange(workers);
var sortedHumans = allHumans.OrderBy(h => h.FirstName).ThenBy(h => h.LastName);
foreach (var human in sortedHumans)
{
Console.WriteLine(human);
}
}
示例2: BindFractionDropDowns
private void BindFractionDropDowns()
{
var fractions = new Collection<ListItem>();
for (int fractionValue = -100; fractionValue <= 100; fractionValue += 5)
{
fractions.Add(new ListItem(fractionValue.ToString()));
}
fractions.Add(new ListItem("11,111"));
fractions.Add(new ListItem("12,5"));
fractions.Add(new ListItem("14,2857"));
fractions.Add(new ListItem("16,666"));
fractions.Add(new ListItem("33,333"));
fractions.Add(new ListItem("66,666"));
fractions.Add(new ListItem("83,333"));
fractions.Add(new ListItem("-11,111"));
fractions.Add(new ListItem("-12,5"));
fractions.Add(new ListItem("-14,2857"));
fractions.Add(new ListItem("-16,666"));
fractions.Add(new ListItem("-33,333"));
fractions.Add(new ListItem("-66,666"));
fractions.Add(new ListItem("-83,333"));
foreach (var control in _answerControls)
{
control.FractionDropDownDataSource = fractions.OrderByDescending(item => DoubleHelper.Parse(item.Text));
control.DataBind();
}
}
示例3: SelectBestLocation
private ViewLocation SelectBestLocation(Collection<ViewLocationMatch> matches)
{
var match = matches.OrderByDescending(m => m.PointsOfMatch).FirstOrDefault();
return match != null ? match.Location : null;
}