0

Here is my code:

Console.WriteLine("X" + 
    characterPosition["position.x"] + 
    " XC: " + 
    (float)Convert.ToDouble(characterPosition["position.x"]));

This prints:

X140,9671 XC: 1409671

How can I convert the string 140,9671 to be float like 140.9671?

gunr2171
  • 16,104
  • 25
  • 61
  • 88
Venelin
  • 2,905
  • 7
  • 53
  • 117
  • 5
    `,` is the decimal separator in many cultures and is apparently the current one on your computer. If you want to output a specific format, you can do that explicitly with format parameters. – crashmstr Nov 25 '19 at 19:51
  • 1
    That depends...what is being returned by `characterPosition["position.x"]`? Is it a **string** or a **numeric type**? – Idle_Mind Nov 25 '19 at 19:54
  • Two duplicates cover all possible combinations of parse/format dot/comma... Side note: disagreeing how your machine is configured to show floating point numbers is not really on-topic on SO... If that's your actual question (how to configure floating point formatting in Windows/Linux) SU would be better place to ask. – Alexei Levenkov Nov 25 '19 at 19:57

0 Answers0