Created
August 3, 2022 23:18
-
-
Save anilkay/e4598ec6e71c824af2bffd7fbdbd4b8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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