OrderBy - Simple
This sample prints an alphabetically sorted version of an input string array. The sample uses orderby to perform the sort.
publicvoid Linqsample()
{
string[] colors = { "Blue", "red", "green" };
var sortedcolorss = from c in colors
orderby c
select c;
Console.WriteLine("The sorted list of colors:");
foreach (var c in sortedcolors)
{
Console.WriteLine(c);
}
}
Result
The sorted list of words:
Blue
green
red
How to open a new window with JavaScript
16 years ago
No comments:
Post a Comment