C#, or any other language (including SQL), does not make differences in the values of floating-point types (float
, double
) based on their representation in your code.
This means that the compiler does not make a difference between:
double v1 = 1;
and
double v2 = 1.000;
Neither does the database where you say (in the comments) you get these values from.
The reason databases display decimals in a certain way is because of a pre-defined formatting applied to the result set. This could either be defined by the database tool you use, or depend on your locale system settings. Anyway, the .NET framework provides you with capabilities to explicitly format your data.
You need to decide which formatting suits your needs best an use it. For instance this will format the number with 4 decimal places after the dot:
String.Format("{0:0.0000}", v1); // outputs 1.0000
String.Format("{0:0.0000}", v2); // outputs 1.0000 too
If you already know your desired format, adjust the formatting string (the first argument that looks like "{0:0000}"
in a way that best corresponds to your requirements.