I want to format the number using ToString(CultureInfo.InvariantCulture) as well as up to 5 decimal places, which can be done using ToString("N5") . How can I do both together?
ToString(CultureInfo.InvariantCulture)
ToString("N5")
How to use overload that accepts both format and culture :
decimal m = 123.4567890123m; string x = m.ToString("N5", CultureInfo.InvariantCulture);
(Obviously, replace double with decimal if you use this; equivalent overload .)
double
decimal
If you have decimal, not double:
string.Format(CultureInfo.InvariantCulture, "{0:f5}", m)
like Decimal.ToString () does not have these overloads