Was sind EVENTS

 

// EVENT-Argumente
// EventArgs

 

 

 

Program.CS Button.CS  

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Delegaten_und_Events

// EVENT-Argumente
// EventArgs

{
class Program
{
static void Main(string[] args)
{
Button b = new Button();
b.KlickEvent += new KlickHandler(MeineKlickMethode);

b.Click();

Console.ReadKey();
}

static void MeineKlickMethode()
{
Console.WriteLine("Zeitstempel");
}

}
}

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Delegaten_und_Events
{
public delegate void KlickHandler();

 

class Button
{
public event KlickHandler KlickEvent;

public void Click()
{
if(KlickEvent != null)
KlickEvent();
}
}


}

 

   
Top