Q:

Delegaes concept using C# Language

0

This Program is used to demonstrate the Delegates concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System; 

    public class Operation 

    { 

        public static void Add(int a, int b) 

        { 

            Console.WriteLine("\nAddition={0}",a + b); 

        } 



        public static void Multiple(int a, int b) 

        { 

            Console.WriteLine("\nMultiply={0}", a * b); 

        } 

    }  



    public class exam 

    { 

        delegate void DelOp(int x, int y); 



      public static void Main() 

        { 

            // Delegate instantiation 

            DelOp[] obj = {new DelOp(Operation.Add),new DelOp(Operation.Multiple)}; 

  

            for (int i = 0; i < obj.Length; i++) 

            { 

                obj[i](2,5); 

                obj[i](8,5); 

                obj[i](4,6); 

            } 

          } 

    } 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now