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); }
public void TestDelegate(string SomeValue, [PacketQueue][UncheckedRemoteExecution] TestDel CallMe) { while (true) { CallMe("some string from Client Side :)"); } }
public TestClass(string themessage) { //creates a delegate instance and assigns the target TestDel thedelegate = new TestDel(ReceiveDelegate); //using the delegate thedelegate(themessage); }
internal static int check_file_not_found (TestDel d){ try { d (); } catch (FileNotFoundException ex){ return 0; } return 1; }
//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); }
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); }
internal static int check_missing_field (TestDel d) { try { d (); } catch (MissingFieldException ex) { //Console.WriteLine (ex); return 0; } return 1; }
public static T First <T>(IEnumerable <T> ienum, TestDel <T> test) { foreach (T t in ienum) { if (test(t)) { return(t); } } return(default(T)); }
public static bool Any <T>(IEnumerable <T> ienum, TestDel <T> test) { foreach (T t in ienum) { if (test(t)) { return(true); } } return(false); }
static void Main(string[] args) { TestDel testDel = Program.Test; typeof(Program).InvokeMember( "ToInvoke", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, new object[] { testDel }); }
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); }
//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()); }
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; }
public static void ToInvoke(TestDel testDel) { testDel(); }
internal static int check_type_load(TestDel d) { try { d (); } catch (TypeLoadException ex) { return 0; } return 1; }
public void CallBack(TestDel deleg, int a, int b) { deleg(a, b); }
static void TestDel() { TestDel v = TestDel; v("测试委托"); }