예제 #1
0
        static void Main(string[] args)
        {
            MultiplynumsDelegate obj = delegate(int x, int y)
            {
                return(x * y);
            };
            double result1 = obj.Invoke(10, 20);//New variable to store the value -return type

            Console.WriteLine(result1);


            QuickDelegate p = delegate(string name1)
            {
                return("Hello" + name1);
            };
            string name = p.Invoke("Yelleti");

            Console.WriteLine(name);

            Addnums2Delegate obj2 = delegate(int x, float y, double z)
            {
                Console.WriteLine(x + y + z);
            };

            obj2.Invoke(10, 3.142f, 123456.7809738);//Non return type

            GreetingsDelegate w = delegate(string wish)
            {
                Console.WriteLine(wish + " " + "Happy Birthday!!!!!!");
            };

            w.Invoke("wish you ");
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            MultiplynumsDelegate obj = new MultiplynumsDelegate(Multiplynums);
            double result1           = obj.Invoke(10, 20);//New variable to store the value -return type

            Console.WriteLine(result1);
            QuickDelegate p    = new QuickDelegate(Quick);
            string        name = p.Invoke("Mumma");

            Console.WriteLine(name);

            Addnums2Delegate obj2 = new Addnums2Delegate(Addnums2);

            obj2.Invoke(10, 3.142f, 123456.7809738);//Non return type

            GreetingsDelegate w = new GreetingsDelegate(Wishes);

            w.Invoke("wish you ");


            CheckLengthDelegate obj3 = new CheckLengthDelegate(CheckLength);//New variable to store the value -return type

            bool check = obj3.Invoke("Haritha");

            Console.WriteLine(check);

            CheckLengthDelegate o = new CheckLengthDelegate(Value);//New variable to store the value -return type

            bool ch = o.Invoke("Maredapaaly");

            Console.WriteLine(ch);


            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {
            MultiplynumsDelegate obj = new MultiplynumsDelegate(Multiplynums);
            double result1           = obj.Invoke(10, 20);//New variable to store the value -return type

            Console.WriteLine(result1);



            GreetingsDelegate w = new GreetingsDelegate(Wishes);

            w.Invoke("happy grduation ");


            CheckLengthDelegate obj1 = new CheckLengthDelegate(CheckLength);//New variable to store the value -return type

            bool check = obj1.Invoke("dhronacharya");

            Console.WriteLine(check);


            Console.ReadLine();
        }
예제 #4
0
        /*//Method with return value
         * public static int Multiplynums(int x, int y)
         * {
         *  return (x * y);
         * }
         *
         * public static string Quick(string name)
         * {
         *  return "Hello" + name;
         * }
         *
         *
         * //method without return value
         * public static void Addnums2(int x, float y, double z)
         * {
         *  Console.WriteLine(x + y + z);
         * }
         * //method without return value
         * public static void Wishes(string wish)
         * {
         *  Console.WriteLine(wish + " " + "Happy Birthday!!!!!!");
         * }
         *
         *
         * public static bool CheckLength(string name)
         * {
         *  //check the string whose length is greater than 4 should print true else false;
         *  if (name.Length > 4)
         *      return true;
         *  return false;
         * }
         * public static bool value(string name1)
         * {
         *  //check the string whose length is greater than 4 should print true else false;
         *  if (name1.Length < 10)
         *      return true;
         *  return false;
         * }*/
        static void Main(string[] args)
        {
            MultiplynumsDelegate obj = delegate(int x, int y)
            {
                return(x * y);
            };
            double result1 = obj.Invoke(10, 20);//New variable to store the value -return type

            Console.WriteLine(result1);


            QuickDelegate p = delegate(string name1)
            {
                return("Hello" + name1);
            };
            string name = p.Invoke("Yelleti");

            Console.WriteLine(name);

            Addnums2Delegate obj2 = delegate(int x, float y, double z)
            {
                Console.WriteLine(x + y + z);
            };

            obj2.Invoke(10, 3.142f, 123456.7809738);//Non return type

            GreetingsDelegate w = delegate(string wish)
            {
                Console.WriteLine(wish + " " + "Happy Birthday!!!!!!");
            };

            w.Invoke("wish you ");


            CheckLengthDelegate obj3 = delegate(string name1)
            {
                //check the string whose length is greater than 4 should print true else false;
                if (name.Length > 4)
                {
                    return(true);
                }
                return(false);
            };


            bool check = obj3.Invoke("Haritha");

            Console.WriteLine(check);

            CheckLengthDelegate o = delegate(string name1)
            {
                //check the string whose length is greater than 4 should print true else false;
                if (name1.Length < 10)
                {
                    return(true);
                }
                return(false);
            };//New variable to store the value -return type

            bool ch = o.Invoke("Maredapaaly");

            Console.WriteLine(ch);


            Console.ReadLine();
        }