Thursday, January 2, 2014

question on delegate predicates

in the following class:

class testLinq
    {
       
        public  bool www(string s)
        { return s.Equals("def"); }

        public delegate bool d(string s);

        public void write()
        {
           
            List<String> l = new List<string>() { "abc", "def" };
             
            normal way of doing predicate:  
            Console.WriteLine(l.Find(p => { return p.Equals("def"); }));
            
            bizzare method: 
            Predicate<string> pred = new Predicate<string>(www); 
            Console.WriteLine(l.Find(pred));

            non working method - 
            d di = null;
            di  = www;
            Console.WriteLine(l.Find(di)));
         Why?



            
            Console.ReadLine();


        }


    }

No comments:

Post a Comment