Q:

How to make sure a zero is always at the end

I need to make sure that a double always ends with 0
6 = 6.0  
5.9876577878 = 5.98765778780

I tried the format but did not bring the expected result.
How can this be done?

A:

Not sure if the String.Format method allows you to do this. Here's something you can do though:
public static class DoubleUtils {
    public static String EnsureEndsWithZero(this double value) {
        String str = value.ToString();
        if(!str.EndsWith("0")) {
            if(str.Contains(".")) {
                str += "0";
            } else {
                str += ".0";
            }
        }
        return str;
    }
}

Usage:
double val = 10.1;
Console.WriteLine(val.EnsureEndsWithZero());

