I am formatting a string.
If there is "0" in the string, I would like to show, 0.00 .
I am using currently the following code that shows 0.0000
string.Format("{0:#,##}",custObject.xx.ToString());
could some one give me some help.
thanks
nath
Printable View
I am formatting a string.
If there is "0" in the string, I would like to show, 0.00 .
I am using currently the following code that shows 0.0000
string.Format("{0:#,##}",custObject.xx.ToString());
could some one give me some help.
thanks
nath
Using formats like that only works if you are formatting a number, not a string. Just because your string includes digit characters doesn't make it a number. You are converting the number to a string with the ToString method, so any format you use in String.Format is useless. Remove the ToString call and you should find that it works. That's because the number will only be converted to a string when the actuall formatting is applied. Note also that if you want the standard numerical format for the current system with two decimal places you should use "n2" as the format string.
you suggestion n2 works.
thanks
nath