LINQ Keywords: orderby |
|
Where is the Condition |
The orderby keyword is used to sort records in a a where condition. Here is an example:
using System;
using System.Linq;
using System.Collections.Generic;
public class Exercise
{
public static int Main()
{
var numbers = new List<int>();
numbers.Add(12);
numbers.Add(45);
numbers.Add(38);
numbers.Add(5);
numbers.Add(128);
numbers.Add(525);
numbers.Add(2448);
numbers.Add(39);
numbers.Add(632);
numbers.Add(207);
var number = from n
in numbers
where n % 2 != 0
orderby n ascending
select n;
foreach (var member in number)
Console.WriteLine(member.ToString());
Console.WriteLine();
return 0;
}
}
This would produce:
|
||
Home | Copyright © 2008-2016, FunctionX, Inc. | Next |
|