private void HandlePropertyChangedEvent(object sender, PropertyChangedEventArgs e) { if (string.Equals(e.PropertyName, nameof(SomeValueText), StringComparison.InvariantCultureIgnoreCase)) { double result; if (Double.TryParse(SomeValueText, out result)) { // Do not allow property changed event if (SomeValue != result) { SomeValue = result; Debug.WriteLine($"New value of SomeValue = {SomeValue}"); } } } if (string.Equals(e.PropertyName, nameof(SomeValue), StringComparison.InvariantCultureIgnoreCase)) { double result; if (Double.TryParse(SomeValueText, out result)) { if (result != SomeValue) { SomeValueText = SomeValue.ToString(); Debug.WriteLine($"New value of SomeValueText = {SomeValueText}"); } } else { SomeValueText = SomeValue.ToString(); Debug.WriteLine($"New value of SomeValueText = {SomeValueText}"); } } }
private void ValueTypeBoxUnbox() { var val = new SomeValue(); Object val1 = val; Object val2 = val; Console.WriteLine(Object.ReferenceEquals(val1, val2)); val.Run(); // call(this somevalue) val.GetType(); // call(this object) val.ToString(); // callvirt Monitor.Enter(val); Monitor.Exit(val); // Error Not Same Object }