Right now I have
double numba = 5212.6312
String.Format("{0:C}", Convert.ToInt32(numba) )
This will give me
$5,213.00
but I don't want the ".00".
I know I can just drop the last three characters of the string every time to achieve the effect, but seems like there should be an easier way.
simple:
numba.ToString("C2")
more @ http://msdn.microsoft.com/pt-br/library/dwhawy9k(v=vs.110).aspx#CFormatString
First - don't keep currency in a
double
- use adecimal
instead. Every time. Then use "C0" as the format specifier:This should do the job:
The number after the
C
specifies the number of decimal places to include.I suspect you really want to be using the
decimal
type for storing such numbers however.click to see Console Out Put screen
Hope this may Help you...
Thanks. :)
I think the right way to achieve your goal is with this:
and only then you should do the Format call: