Skip to content

Instantly share code, notes, and snippets.

@jhalbrecht
Created August 30, 2011 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhalbrecht/1180138 to your computer and use it in GitHub Desktop.
Save jhalbrecht/1180138 to your computer and use it in GitHub Desktop.
My first attempt with Int32.TryParse
private string _Angle;
public string Angle {
get {
return this._Angle;
}
set {
if (value != this._Angle) {
this._Angle = value;
NotifyPropertyChanged("Angle");
//}
// set intAngle an integer version of the sting Angle
int _intAngle;
bool isGood = Int32.TryParse(this._Angle, out _intAngle);
if (isGood) {
this.intAngle = _intAngle;
NotifyPropertyChanged("intAngle");
}
else { // I don't think I need the else although a range and an angle = a vector
// if either angle or range is a bad conversion the other should be discarded too.
}
}
}
}
public int intRange { get; set; }
public int intAngle { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment