Si avrebbe bisogno di rompere il sopra in a soci privati / pubblici in modo da non avere problemi ricorsivi:
private float _inverseMass;
public float inverseMass
{
get { return this._inverseMass; }
set { this._inverseMass = value; onMassChanged(); }
}
Tuttavia, hai guardato all'interfaccia INotifyPropertyChanged
? Fa praticamente quello che stai cercando e, a seconda di cosa stai scrivendo, potrebbe essere supportato in modo nativo.
public class MyClass : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String property)
{
var event = this.PropertyChanged;
if (event != null)
{
event(this, new PropertyChangedEventArgs(property));
}
}
private float _inverseMass;
public float inverseMass
{
get { return this._inverseMass; }
set { this._inverseMass = value; NotifyPropertyChanged("inverseMass"); }
}
}
fonte
2012-01-03 20:09:23
Non è possibile farlo in C#. Devi usare un campo di supporto. –
La risposta è SI .... creerebbe un ciclo continuo. –
@UweKeim, quella dovrebbe essere una risposta. – driis