Skip to content

Instantly share code, notes, and snippets.

@anilkay
Created August 3, 2022 23:18
Show Gist options
  • Select an option

  • Save anilkay/e4598ec6e71c824af2bffd7fbdbd4b8f to your computer and use it in GitHub Desktop.

Select an option

Save anilkay/e4598ec6e71c824af2bffd7fbdbd4b8f to your computer and use it in GitHub Desktop.
public class Speed(){
public void Main(){
Example example=new Example();
example.SpeedValueChanged += delegate (int speed)
{
Console.WriteLine("Speed changed: " + speed);
};
example.SpeedValueChanged += (int speed)=>
{
if(speed > 70)
{
Console.WriteLine("You are too fast");
}
};
example.Speed = 20;
example.Speed = 100;
}
}
public delegate int MyEventHandler();
public delegate void SpeedValueChangedEventHandler(int value);
public class Example
{
private int _speed;
public int Speed
{
get
{
return this._speed;
}
set
{
SpeedValueChanged(value);
_speed = value;
} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment