Friday, January 22, 2010

Order by Array Using LINQ :

public void Linq28()
{
string[] words = { "cherry", "apple", "blueberry" };

var sortedWords =
from w in words
orderby w
select w;

Console.WriteLine("The sorted list of words:");
foreach (var w in sortedWords)
{
Console.WriteLine(w);
}
}

Result

The sorted list of words:
apple
blueberry
cherry

0 comments:

Post a Comment