ToList

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

var sortedWords =
from w in words
orderby w
select w;
var wordList = sortedWords.ToList();

Console.WriteLine("The sorted word list:");
foreach (var w in wordList)
{
Console.WriteLine(w);
}
}
Lambda Expression
public void Linq55()
{
string[] words = { "cherry", "apple", "blueberry" };

var sortedWords =
from w in words
orderby w
select w;
var wordList = sortedWords.ToList();

Console.WriteLine("The sorted word list:");
foreach (var w in wordList)
{
Console.WriteLine(w);
}
}
Output
The sorted word list:
apple
blueberry
cherry
Related Tutorial
1. ToArray
2. ToList

4. OfType
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 # # # # #