Is there a way to continue to utilise auto-implemented properties while still raising a change event, such as INotifyPropertyChanged, when Set is called?
Instead of:
private string _value;
public string Value
{
get
{
return this._value;
}
set
{
this._value = value;
this.ValueChanged(this,EventArgs.Empty);
}
}
Can I just do:
public string Value
{
get;
set
{
this.ValueChanged(this,EventArgs.Empty);
}
}
Although the setter looks wrong, is it possible to do this without filling my class with backing-store variables?
UPDATE: Looks like there is no standard solution to my lazy objective, I think that the best solution is to use CodeRush or Resharper to generate all my backing stores for me.
You can’t do this. The specification for automatically implemented properties is pretty clear:
In other words, they can only have “
get;” and “set;“, with the possibility of access modifiers.