How to intelligently & safely convert a Double to String?
If you could live with strings like 00, 05, 10, 15, 20 ...
etc., you could simply use
(rating * 10).ToString("00")
If not, use InvariantCulture
as argument to ToString
in order to force the use of a decimal point (".") in all countries (in Germany the default would be "," for example):
rating.ToString(CultureInfo.InvariantCulture).Replace(".","");
Decimal delimiter depends on current culture preferences:
d.Replace(
System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator,
String.Empty)
will replace '.'
or ','
with ""