static void Main(string[] args) { AddnumsDelegate obj1 = delegate(int x, float y) //object creation { return(x + y); }; double result = obj1.Invoke(5, 5.5f); //Invoke Method Console.WriteLine(result); MultiplyDelegate obj2 = delegate(int x, int y) //object creation { return(x + y); }; int result1 = obj2.Invoke(50, 50); //Invoke Method Console.WriteLine(result1); NamesDelegate obj3 = delegate(string Abhigna) //object creation { return(" This " + Abhigna + " my "); }; string result2 = obj3.Invoke("is"); //Invoke Method Console.WriteLine(result2); WishDelegate obj4 = delegate(String sir) //object creation { return(" practise " + sir + " yes "); }; string result3 = obj4.Invoke("file "); //Invoke Method Console.WriteLine(result3); CheckLengthDelegate obj5 = delegate(string name) //object creation { if (name.Length > 5) { return(true); } return(false); }; bool check = obj5.Invoke(" sir "); //Invoke Method Console.WriteLine(check); CheckLength1Delegate obj6 = delegate(string namee) //object creation { if (namee.Length < 3) { return(true); } return(false); }; bool check1 = obj6.Invoke(" AbhignaThammana ");//Invoke Method Console.WriteLine(check1); Console.ReadLine(); }
static void Main(string[] args) { AddnumsDelegate obj1 = (int x, float y) => //Lambda expression { return(x + y); //return operation }; double result = obj1.Invoke(5, 5.5f); //Invoking values Console.WriteLine(result); MultiplyDelegate obj2 = (int x, int y) => { return(x + y); }; int result1 = obj2.Invoke(50, 50); Console.WriteLine(result1); NamesDelegate obj3 = Ramya => { Console.WriteLine(" Hai " + Ramya + " welcome "); }; obj3.Invoke("Ramya"); Console.ReadLine(); }
static void Main(string[] args) { AddnumsDelegate obj1 = delegate(int x, int y) //object creation { return(x + y); }; int result = obj1.Invoke(5, 5); Console.WriteLine(result); MultiplyDelegate obj2 = delegate(int x, float y) //object creation { return(x * y); }; double result1 = obj2.Invoke(3, 3.4f); Console.WriteLine(result1); CheckLengthDelegate obj3 = delegate(string name) { if (name.Length > 3) { return(true); } return(false); }; bool check = obj3.Invoke("CSHARP"); Console.WriteLine(check); Console.ReadLine(); }
static void Main(string[] args) { AddnumsDelegate obj1 = (int x, float y) => { return(x + y); }; double result = obj1.Invoke(5, 5.5f); Console.WriteLine(result); MultiplyDelegate obj2 = (int x, int y) => { return(x + y); }; int result1 = obj2.Invoke(50, 50); Console.WriteLine(result1); NamesDelegate obj3 = was => { Console.WriteLine(" This " + was + " my "); }; obj3.Invoke("was"); WishDelegate obj4 = sir => { Console.WriteLine(" my " + sir + "file "); }; obj4.Invoke("practice "); CheckLengthDelegate obj5 = name => { if (name.Length > 5) { return(true); } return(false); }; bool check = obj5.Invoke(" Sowmya "); Console.WriteLine(check); CheckLength1Delegate obj6 = namee => { if (namee.Length < 3) { return(true); } return(false); }; bool check1 = obj6.Invoke(" Ramyasree "); Console.WriteLine(check1); Console.ReadLine(); }
static void Main(string[] args) { AddnumsDelegate obj1 = new AddnumsDelegate(Addnums); int result = obj1.Invoke(5, 5); Console.WriteLine(result); MultiplyDelegate obj2 = new MultiplyDelegate(Multiply); double result2 = obj2.Invoke(4, 5); Console.WriteLine(result2); MethodDelegate obj3 = new MethodDelegate(Method); obj3.Invoke("RAMYA"); Console.ReadLine(); }
static void Main(string[] args) { //instatiation and invoking of method 1 MulnumsDelegate obj1 = new MulnumsDelegate(Mulnums); double result1 = obj1.Invoke(5, 3.5f, 3456.68763); Console.WriteLine(result1); //instatiation and invoking of method 2 AddnumsDelegate obj2 = new AddnumsDelegate(Addnums); double result2 = obj2.Invoke(5, 3.5f, 3456.68763); Console.WriteLine(result2); //instatiation and invoking of method 3 SubnumsDelegate obj3 = new SubnumsDelegate(Subnums); obj3.Invoke(5, 3.5f, 3456.68763); // //instatiation and invoking of method 4 Subnums1Delegate1 obj4 = new Subnums1Delegate1(Subnums1); obj4.Invoke(5, 3.5f, 3456.68763); //instatiation and invoking of method 5 checkevenDelegate obj5 = new checkevenDelegate(checkeven); bool check = obj5.Invoke(4); Console.WriteLine(check); //instatiation and invoking of method 6 checkoddDelegate obj6 = new checkoddDelegate(checkodd); bool checks = obj6.Invoke(4); Console.WriteLine(checks); Console.ReadLine(); }