daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Apr 19th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace EventsPractice
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             Point point = new Point();
  8.  
  9.             point.PointChanged += HandlePointChanged;
  10.         }
  11.  
  12.     }
  13.     class Point
  14.     {
  15.         private double x;
  16.         private double y;
  17.  
  18.         public double X
  19.         {
  20.             get { return x; }
  21.             set
  22.             {
  23.                 x = value;
  24.                 OnPointChanged();
  25.             }
  26.         }
  27.         public double Y
  28.         {
  29.             get { return y; }
  30.             set
  31.             {
  32.                 y = value;
  33.                 OnPointChanged();
  34.             }
  35.  
  36.         }
  37.  
  38.         public event EventHandler PointChanged;
  39.  
  40.         public void OnPointChanged()
  41.         {
  42.             if (PointChanged != null)
  43.                 PointChanged(this, EventArgs.Empty);
  44.         }
  45.  
  46.         public void HandlePointChanged(object sender, EventArgs eventArgs)
  47.         {
  48.             // Do something Here
  49.         }
  50.  
  51.     }
  52. }
  53.    
  54. point.PointChanged += HandlePointChanged;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top