예제 #1
0
        static void Main(string[] args)
        {
            //net 1
            var helper     = new Helper();
            var deleMwthod = new AddMethodDelegate(helper.CustomAdd);

            new DelagateSample().UseDeleGate(deleMwthod);
            // net 2
            new DelagateSample().UseDeleGate(delegate(int a) { return(helper.CustomAdd(a)); });
            // net 3
            new DelagateSample().UseDeleGate(a => helper.CustomAdd(a));

            Action <int> exam = x =>
            {
                Console.WriteLine(x); Console.ReadKey();
            };

            exam(6);


            Func <string, string> example = x => { return(x + "good"); };

            Console.WriteLine(example("boy"));
            Console.ReadKey();

            helper.Run(x => { Console.WriteLine(x); Console.ReadKey(); });
            //Func<object> exm=null;
            //var user = HttpContext.Current.CacheRead<Func<Object>> ("k1", 2,()=> new UserManagement().FindUser(2));
        }
예제 #2
0
 public void UseDeleGate(AddMethodDelegate addMethod)
 {
     Console.WriteLine(addMethod(5));
     Console.ReadKey();
 }