Example #1
0
    static void Main1()
    {
        SampleDel add = delegate(int x, int y)
        {
            Console.WriteLine(x + y);
        };
        SampleDel mul = delegate(int x, int y)
        {
            Console.WriteLine(x * y);
        };

        TestDel   Line   = () => Console.WriteLine("=====================");
        SampleDel Series = (no1, no2) =>
        {
            for (int i = no1; i <= no2; i++)
            {
                Console.WriteLine(i);
            }
        };

        Line();
        Series(3, 7);
        Calc(add);
        Calc(mul);
    }
Example #2
0
 public void TestDelegate(string SomeValue, [PacketQueue][UncheckedRemoteExecution] TestDel CallMe)
 {
     while (true)
     {
         CallMe("some string from Client Side :)");
     }
 }
Example #3
0
        public TestClass(string themessage)
        {
            //creates a delegate instance and assigns the target
            TestDel thedelegate = new TestDel(ReceiveDelegate);

            //using the delegate
            thedelegate(themessage);
        }
Example #4
0
	internal static int check_file_not_found (TestDel d){
		try {
			d ();
		} catch (FileNotFoundException ex){
			return 0;
		}
		return 1;
	}
Example #5
0
        //bool TestDel2(string v)
        //{
        //    Console.WriteLine(v);
        //    return true;
        //}

        static void TestEvent()
        {
            notify += Test_notify;

            TestDel v = Test.TestDel;

            notify += v;
            _notify("你好");
        }
 internal static int check_file_not_found(TestDel d)
 {
     try {
         d();
     } catch (FileNotFoundException ex) {
         return(0);
     }
     return(1);
 }
Example #7
0
        private static void DelegatesFunc()
        {
            DelegatesDemo obj = new DelegatesDemo();
            TestDel       td  = obj.AddNums;

            td(1, 2, 3);
            SayDel sd = DelegatesDemo.SayHello;

            sd("VISHU");
        }
        static void Main()
        {
            //anonymous method
            TestDel del = delegate(string name)
            {
                return("hello " + name);
            };
            string message = del("joydip");

            Console.WriteLine(message);
        }
Example #9
0
	internal static int check_missing_field (TestDel d) {
		try {
			d ();
		}
		catch (MissingFieldException ex) {
			//Console.WriteLine (ex);
			return 0;
		}

		return 1;
	}
Example #10
0
 public static T First <T>(IEnumerable <T> ienum, TestDel <T> test)
 {
     foreach (T t in ienum)
     {
         if (test(t))
         {
             return(t);
         }
     }
     return(default(T));
 }
Example #11
0
 public static bool Any <T>(IEnumerable <T> ienum, TestDel <T> test)
 {
     foreach (T t in ienum)
     {
         if (test(t))
         {
             return(true);
         }
     }
     return(false);
 }
Example #12
0
    static void Main(string[] args)
    {
        TestDel testDel = Program.Test;

        typeof(Program).InvokeMember(
            "ToInvoke",
            BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static,
            null,
            null,
            new object[] { testDel });
    }
Example #13
0
	internal static int check_type_load (TestDel d) {
		try {
			d ();
		}
		catch (TypeLoadException ex) {
			//Console.WriteLine (ex.TypeName);
			//Console.WriteLine (ex);
			return 0;
		}

		return 1;
	}
    internal static int check_missing_field(TestDel d)
    {
        try {
            d();
        }
        catch (MissingFieldException ex) {
            //Console.WriteLine (ex);
            return(0);
        }

        return(1);
    }
    internal static int check_type_load(TestDel d)
    {
        try {
            d();
        }
        catch (TypeLoadException ex) {
            //Console.WriteLine (ex.TypeName);
            //Console.WriteLine (ex);
            return(0);
        }

        return(1);
    }
Example #16
0
        //v2
        //static string[] Where(string[] items, Func<string, bool> test)
        //v1
        static string[] Where(string[] items, TestDel test)
        {
            var result = new List <string>();

            foreach (var item in items)
            {
                if (test(item))
                {
                    result.Add(item);
                }
            }
            return(result.ToArray());
        }
Example #17
0
        static void Main(string[] args)
        {
            TestDel testDel = (int n) =>
            {
                Console.WriteLine(n);
            };
            TestDel testDel2 = (int n) =>
            {
                for (int i = 0; i < 5; i++)
                {
                    Console.WriteLine(n);
                }
            };

            testDel2(5);
            Console.Read();
        }
    internal static int check_missing_method(TestDel
d)
    {
        try
        {
        d
        ();
        }
        catch
        (MissingMethodException
        ex)
        {
        return
        0;
        }
        return
        1;
    }
Example #19
0
 public static void ToInvoke(TestDel testDel)
 {
     testDel();
 }
    internal static int check_type_load(TestDel
d)
    {
        try
        {
        d
        ();
        }
        catch
        (TypeLoadException
        ex)
        {
        return
        0;
        }
        return
        1;
    }
Example #21
0
 public void CallBack(TestDel deleg, int a, int b)
 {
     deleg(a, b);
 }
Example #22
0
        static void TestDel()
        {
            TestDel v = TestDel;

            v("测试委托");
        }