Why not create an extension method for double
? It should return the string-converted double
-- formatted with the precision you want (8 decimal places). So that the calling function can just specify a format string.. nothing else.. no need to specify a numeric precision.
Something like:
static string ToPreciseString(this double data)
{
return String.Format("{0:F8}", data);
}
So the function you are creating can just be something like:
void MyFunction(string stringFormatWithoutPrecision)
{
double anyDoubleValue; //i dont know where you get the double data from
string formattedData = String.Format(stringFormatWithoutPrecision, anyDoubleValue.ToPreciseString());
}