Find a format string for a decimal without % sign [duplicate]
Possible Duplicate:
How to format a number as percentage without the percentage sig开发者_Go百科n?
I have a decimal:
decimal value = 0.0123m;
The format string "P" will return a string which value is multiple with 100 and add sign % at the end. Example:
string s = value.ToString("P"); // s = "1.23 %"
Please help me to find a format string without including % sign on returned string.
That mean: s will be "1.23" (without sign %)
Please help me. Thanks.
You can set the PercentSymbol
property of the NumberFormatInfo
to be something other than a % sign.
In your case you could just set it to be an empty string.
More info here
To do this you'll need to define a custom culture with its own NumberFormatInfo
. The link to the answer provided in the comments in a great solution:
How to format a number as percentage without the percentage sign?
精彩评论