Mega Code Archive

 
Categories / C# Tutorial / LINQ
 

Pass the delegates into the methods of Sequence

using System; using System.Collections.Generic; using System.Text; using System.Xml.Linq; using System.Linq;     class Program     {         static void Main(string[] args)         {             string[] currentVideoGames = {"test", "this is a test",                            "asdf", "game 1",                           "game 2", "game 3"};             Func<string, bool> searchFilter = delegate(string game) { return game.Length > 6; };             Func<string, string> itemToProcess = delegate(string s) { return s; };             var subset = currentVideoGames                 .Where(searchFilter).OrderBy(itemToProcess).Select(itemToProcess);             foreach (var game in subset)                 Console.WriteLine("Item: {0}", game);         }     }