c# - Custom where method -


i have project can't use system.linq, trying create cutsom method works same linq, how can that?

var x = y.tolist().where(t => t.title != "foo"); 

solution 1

protected void page_load(object sender, eventargs e) {     var x = y.tolist().where<microsoft.sharepoint.navigation.spnavigationnode>(x => x.title != "foo"); }  public static class extensions {     public static ienumerable<t> where<t>(this ienumerable<t> source, func<t, bool> filter)     {         foreach (var item in source)         {             if (filter(item))                 yield return item;         }     } } 

note : .net v 2.0

here's extension method:

public static ienumerable<t> where<t>(this ienumerable<t> source, func<t, bool> filter)  {     foreach (var item in source)     {         if (filter(item))             yield return item;     } } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -