I\'m reading the Pro MVC 2 book, and there is an example of creating an extension method for the HtmlHelper class.
Here the code example:
public stat
Have a blog post on this. Using Func
you can resolve some of functional discrepancy. Read here.
I have implemented a where() extension method using Func please have a look...
public static IEnumerable<Tsource> Where<Tsource> ( this IEnumerable<Tsource> a , Func<Tsource , bool> Method )
{
foreach ( var data in a )
{
//If the lambda Expression(delegate) returns "true" Then return the Data. (use 'yield' for deferred return)
if ( Method.Invoke ( data ) )
{
yield return data;
}
}
}
You can use it like,
foreach ( var item in Emps.Where ( e => e.Name == "Shiv" ).Select ( e1 => e1.Name ) )
{
Console.WriteLine ( item );
}