I am trying to monitor an int object for changes in c#. Below is my code. I am looking for a new solution as this does not scale well and each time I want to monitor and object I need to create a new class.
Code:
< delegate void StateChangeHandler(int newGolferID);
 
     static class Golfer
      {
         private static int _GolferID;
         public static int GolferID
          {
             get { return _GolferID;  }
             set
              {
                 if (_GolferID != value)
                  {
                      _GolferID = value;
                      Properties.Settings.Default.golferID = value;
                      Properties.Settings.Default.Save();
                      notify();
                  }
              }
          }
 
         private static event StateChangeHandler  _onChange;
         public static event StateChangeHandler  OnStateChange
          {
             add
              {
                 _onChange +=  value;
              }
             remove
              {
                 _onChange -=  value;
              }
          }
 
         private static void notify()
          {
             if (_onChange != null)
              {
                  _onChange(_GolferID);
              }
          }
     }