event c sharp code example

Example 1: c# event

private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) 
{
}

private void panel1_MouseEnter(object sender, System.EventArgs e) 

private void panel1_MouseHover(object sender, System.EventArgs e) 
  
private void panel1_MouseLeave(object sender, System.EventArgs e)
  
private void panel1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
  
private void panel1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
       
private void panel1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) 

private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) 

private void clearButton_Click(object sender, System.EventArgs e)  
  
0

Example 2: events in c# geeksforgeeks

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace event_programming{    //This is Subscriber Class    class Program    {        static void Main(string[] args)        {            AddTwoNumbers a = new AddTwoNumbers();            //Event gets binded with delegates            a.ev_OddNumber += new AddTwoNumbers.dg_OddNumber(EventMessage);            a.Add();            Console.Read();        }              //Delegates calls this method when event raised.          static void EventMessage()        {            Console.WriteLine("********Event Executed : This is Odd Number**********");        }    }    //This is Publisher Class    class AddTwoNumbers    {                public delegate void dg_OddNumber(); //Declared Delegate             public event dg_OddNumber ev_OddNumber; //Declared Events         public void Add()        {            int result;            result = 5 + 4;            Console.WriteLine(result.ToString());            //Check if result is odd number then raise event            if((result % 2 != 0) && (ev_OddNumber != null))            {                ev_OddNumber(); //Raised Event            }                  }    }}