Click here to Skip to main content
16,005,241 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
{
    public delegate void Mydel(int a);
    class Program
    {
        //this is ok
        public static event Mydel _MyEvt;
        static void Main(string[] args)
        {

          //Can i define event in this part give some error
            public static event Mydel _MyEvt;
            opreation g = new opreation();

            _MyEvt += new Mydel(g.Hello);
            //_MyEvt += new Mydel(Greet.Hi);
            //_MyEvt += new Mydel(Greet.Bye);
            start();
            Console.ReadKey();
        }
        public static void start()
        {
               //i emplement uing abstract method but i want as normal method
            //can i pass parameter to event as normal
            int a;
            Console.WriteLine("Enter Parameter=");
            a = Convert.ToInt32(Console.ReadLine());
            _MyEvt(a);

        }
    }
}
Posted
Updated 4-Mar-14 8:25am
v2
Comments
AjitRaje 4-Mar-14 13:01pm    
plz comment in program is my question to find solu...
Krunal Rohit 4-Mar-14 13:02pm    
Okay !

-KR
BillWoodruff 4-Mar-14 13:51pm    
Please describe what your goal is here, and the specific error messages you get.
AjitRaje 5-Mar-14 2:20am    
@Krunal Rohit
Can we decelar event object in static void main()method like

static void Main(string[] args)
{

//Can i define event in this part give some error
//Mydel is delegate name
public static event Mydel _MyEvt;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900