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();
        }
Example #2
0
        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();
        }
Example #3
0
        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 = AddNums;
            double          b    = obj1.Invoke(100, 3.9f, 200);

            Console.WriteLine(b);

            NamesDelegate obj2 = Names;

            obj2.Invoke("laxman");

            DecisionsDelegates obj3 = Decision;
            bool t = obj3.Invoke("laxman");

            Console.WriteLine(t);
            Console.Read();
        }