Reputation: 20688
I Have used following code to format decimals
return string.Format(CultureInfo.CreateSpecificCulture("nb-NO"), "{0:N3}", decVal);
If the decVal do not contain decimals I do not want to show decimal points but I want to show the figure with the correct formatting without zero s , How to perform this ?
Upvotes: 4
Views: 285
Reputation: 10401
You can use custom numeric format like:
return string.Format(CultureInfo.CreateSpecificCulture("nb-NO"), "{0:0.###}", decVal);
You may want to read about standard numeric formats and custom numeric formats
EDIT:
To handle the thousands separators you could use:
return string.Format(CultureInfo.CreateSpecificCulture("nb-NO"), "{0:#,0.###}", decVal);
But, to handle some specific cases you'd better to implement formats like it is described in this SO thread.
P.S.: Thanks @Luaan for the (0.###);
Upvotes: 9