I have c# project. I use ToString("N", CultureInfo.CurrentCulture)
for format double value and the result is like 1.254.812,45 .There is no problem. But when I have no precision I don’t want to display 1.254.812,00. I want to display only 1.254.812 . How can I do it?
2
Answers
I don’t know if there is a direct solution, but the
Convert()
method I developed provides a solution.This code produces the following output:
You can use the custom format specifier
#
, which only returns decimal digits if they exist in the number, both before the decimal point and after.For example, for
de-DE
culture:Output
dotnetfiddle