Input:
string[] names = { "Ajay", "Vijay", "Karan", "Farhan", "Pooja", "Geeta", "Dia" };
Lambda Expression:
IEnumerable
.OrderBy(n=> n.Length)
.Select(n => n.ToUpper());
Comprenesion Query:
IEnumerable
where n.EndsWith("a")
orderby n.Length
select n.ToUpper();
Enumerate result:
foreach (string str in tp)
{
Console.WriteLine(str);
}
Output:
DIA
POOJA
GEETA
Main Points:
1. We have option to use either lambda expressions or comprehension query to get the desired result.
2. Compiler converts comprehension query to lambda expression.
very good article for beginners. Please post the complete linq tutorial. Plz also notify me :bthshariff@gmail.com
ReplyDeleteThanks Hussain.
ReplyDelete