Select - Anonymous Types 1

Query
public void Linq9()
{
string[] words = { "aPPLE", "BlUeBeRrY", "cHeRry" };

var upperLowerWords =
from w in words
select new { Upper = w.ToUpper(), Lower = w.ToLower() };

foreach (var ul in upperLowerWords)
{
Console.WriteLine("Uppercase: {0}, Lowercase: {1}", ul.Upper, ul.Lower);
}
}
Lambda Expression
public void DataSetLinq9()
{
var words = testDS.Tables["Words"].AsEnumerable();

var upperLowerWords = words.Select(p => new
{
Upper = (p.Field(0)).ToUpper(),
Lower = (p.Field(0)).ToLower()
});

foreach (var ul in upperLowerWords)
{
Console.WriteLine("Uppercase: " + ul.Upper + ", Lowercase: " + ul.Lower);
}
}
Output
Uppercase: APPLE, Lowercase: apple
Uppercase: BLUEBERRY, Lowercase: blueberry
Uppercase: CHERRY, Lowercase: cherry
Related Tutorial