Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace EventsPractice
- {
- class Program
- {
- static void Main(string[] args)
- {
- Point point = new Point();
- point.PointChanged += HandlePointChanged;
- }
- }
- class Point
- {
- private double x;
- private double y;
- public double X
- {
- get { return x; }
- set
- {
- x = value;
- OnPointChanged();
- }
- }
- public double Y
- {
- get { return y; }
- set
- {
- y = value;
- OnPointChanged();
- }
- }
- public event EventHandler PointChanged;
- public void OnPointChanged()
- {
- if (PointChanged != null)
- PointChanged(this, EventArgs.Empty);
- }
- public void HandlePointChanged(object sender, EventArgs eventArgs)
- {
- // Do something Here
- }
- }
- }
- point.PointChanged += HandlePointChanged;
Add Comment
Please, Sign In to add comment