I got a critical comment from @amazedsaint. You can read his blog http://amazedsaint.blogspot.com/
If you read my previous post http://dhananjaykumar.net/2010/10/01/findall-finding-multiple-items-in-c-list/ ,
I am using a method GreaterThanHunAs predicate to pass as parameter to FindAll()
Instead of that we can use
So, I am going to show you here how we could use Lambda expression
List<int>lstgrthund = lst.FindAll(a=>a>100? true:false);
So here we are just writing a lambda instead of calling a function.
Program.cs
using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; namespace ConsoleApplication24 { classProgram { staticvoid Main(string[] args) { List<int>lst = newList<int>(); lst.Add(20); lst.Add(300); lst.Add(400); lst.Add(9); lst.Add(19); lst.Add(789); lst.Add(45); List<int>lstgrthund = lst.FindAll(a=>a>100? true:false); foreach (var r inlstgrthund) { Console.WriteLine(r); } Console.ReadKey(true); } } }
Output
Tags: #DOTNET, #ASP.NET, ASP.NET, BRH, .NET,