c# - How to parse the values to string in Windows Phone? -
how parse double format values (distance, calories) string format? taken in textblock. need convert them string in button clickevent.
private void positionchanged(object sender, geopositionchangedeventargs<geocoordinate> e) { var coord = new geocoordinate(e.position.location.latitude, e.position.location.longitude); var calories = calorieslabel.text; var previouspoint = _line.path.last(); var distance = coord.getdistanceto(previouspoint); var millisperkilometer = (1000.0 / distance) * (system.environment.tickcount - _previouspositionchangetick); _kilometres += distance / 1000.0; pacelabel.text = timespan.frommilliseconds(millisperkilometer).tostring(@"mm\:ss"); distancelabel.text = string.format("{0:f2} km", _kilometres); calorieslabel.text = string.format("{0:f0}", _kilometres * 65); }
you use, example,
double d = 13.000; string.format("{0:0.000}km", d)
or pass format parameter tostring method.
string s = d.tostring("0.000 km"); console.writeline(s);
if "0.000" not passed parameter 13 displayed.hope helps
Comments
Post a Comment