convert double to string using "." as decimal seperator regardless of locale

Need help to convert a double or decimal to a string using the "." as decimal seperator regardless of the locale settings of the user. Any ideas
In VB this can be done using the Str() function which is under the Microsoft.VisualBasic namespace, however I would like something more generic.



Answer this question

convert double to string using "." as decimal seperator regardless of locale

  • bali

    Maybe this would help

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemconvertclasstostringtopic22.asp

  • Grandote945

    Indeed it helps! Thanks. I was thinking to use the following but the approach you the specific article recommends seems to be much more elegant!



    decimal num = 23.343;

    return num.ToString().Replace(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".");


     


  • convert double to string using "." as decimal seperator regardless of locale