Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SimpleDelegate sd = new SimpleDelegate();

            // this is the delegate instantiation
            Comparer cmp = new Comparer(Name.CompareFirstNames);

            Console.WriteLine("\nBefore Sort: \n");

            sd.PrintNames();

            // observe the delegate argument
            sd.Sort(cmp);

            Console.WriteLine("\nAfter Sort: \n");

            sd.PrintNames();
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            SimpleDelegate d = DoSimple;

            d();

            List <int> numbers = Enumerable.Range(0, 10).ToList();



            Console.WriteLine("Enter a boundary:");
            int boundary = Int32.Parse(Console.ReadLine());

            b = boundary;

            Predicate <int> p = IsGreaterThanX;

            numbers.Find(p);

            var i = numbers.Find(n => n > boundary);

            Console.WriteLine(i);
            Console.ReadLine();
        }