Die EVENT-ARGUMENTE

 

 

 

 

 

Program.CS Button.CS EventArgs.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(EventArgs args)
{
Console.WriteLine(args.parameter2);
}



}
}

 

 

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

namespace Delegaten_und_Events
{

 

class Button
{
public event KlickHandler KlickEvent;

public void Click()
{
EventArgs args = new EventArgs();
args.parameter1 = 20;
args.parameter2 = 30;

if(KlickEvent != null)
KlickEvent(args);
}
}

public delegate void KlickHandler(EventArgs args);
}

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

namespace Delegaten_und_Events
{
public class EventArgs
{


public int parameter1 { get; set; }
public int parameter2 { get; set; }
}
}

Top