Created
August 30, 2011 03:53
-
-
Save jhalbrecht/1180138 to your computer and use it in GitHub Desktop.
My first attempt with Int32.TryParse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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