I am using a propertygrid in C# to get double values form the user, these values are diameters of circles and the user will input the diameters for example "25", but I want after typing and mouse leave the displayed value becomes like this "25.00 cm" (without quotes), meaning to add .00 and "cm" but I can't implement this as I get an error for converting double to string. Any help will be appreciated.
Asked
Active
Viewed 1,970 times
1
-
2Cast the double as a string before you try to concatenate them. Use double.ToString(). – eddie_cat Sep 03 '14 at 20:53
1 Answers
3
double v = 10;
string s = v.ToString(); // "10"
string f = string.Format("{0:0.00} cm", v); // "10.00 cm"

Kyle W
- 3,702
- 20
- 32