I need an event to fire when I change a property. When I run this code I get a Object reference not set to an instance of an object. What am I doing wrong? What is the correct way to instantiate an event, and fire it when a property is set?
public member:
public event System.EventHandler ClassChanged;
property set:
ClassChanged(this, EventArgs.Empty);
You need to verify the event handler it not null first:
But in general, you may want to wrap this up into a helper method like so:
Or possibly implement INotifyPropertyChanged instead.