|
-
Jun 8th, 2006, 06:43 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2.0] string format help..
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
-
Jun 8th, 2006, 07:45 PM
#2
Re: [2.0] string format help..
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.
-
Jun 9th, 2006, 10:01 AM
#3
Thread Starter
Hyperactive Member
Re: [2.0] string format help..
you suggestion n2 works.
thanks
nath
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|