Introduction:
In this article demonstrates,the effective use of lambda expressions in LINQ.
Main:
What is lambda expressions?
Simply a lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.
Here some simple exambles,
ex 1:
string[] ArrNumbers = {"One","Two","Three","Four","Five"};
foreach (var no in ArrNumbers.Where((n) => n.StartsWith("T"))) //Just we are getting a text starts with "T" Result:Two,Three
{
Response.Write(no);
}
ex 2:
int[] Arrnumbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };
var evenNumQuery =
from num in numbers
where (num % 2) == 0
select num;
ex 1: string[] ArrNumbers = {"One","Two","Three","Four","Five"}; foreach (var no in ArrNumbers.Where((n) => n.StartsWith("T"))) //Just we are getting a text starts with "T" Result:Two,Three { Response.Write(no); } ex 2: int[] Arrnumbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 }; var evenNumQuery = from num in numbers where (num % 2) == 0 select num; |
Conclusion:
Hope this helps,
Happy Coding.
Keep posting stuff like this i really like it
Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
My cousin recommended this blog and she was totally right keep up the fantastic work!
Great site. A lot of useful information here. I’m sending it to some friends!
Heya, your website is on air in the radio! Fine work mate. Your blogposts are definitely very good and saved in bookmarks. CYa
I’m glad I found your site through google , really enjoyed it. Thank you..
Thank you very much for posting all of the great content! Looking forward to reading more posts!
This nice post encouraged me a lot! Saved the website, extremely interesting topics just about everywhere that I read here! I really like the information, thanks.
Helpful blog, bookmarked the site in hopes to see more information!