Search code examples
c#linuxmonoraspberry-pi2

Mono fails to convert string to double


I've created a little tool which reads the text from a txt file and processed it.

string seconds = null;
string temp = null;
double timetaken = 0.0;

seconds = (File.ReadAllText("file.txt"));
temp = seconds.Replace('.', ',');
timetaken = double.Parse(temp);

My problem now is that it runs without problems on Windows, but craches on Linux with mono(raspberry-pi2)

The txt file always just contains one line with 11 characters for example: 0.080983088

I know that the problems is double.Parse, but I dont know what to do, I already tried Convert.todouble and double.tryparse, but it didn't help.

error log


Solution

  • timetaken = Convert.ToDouble(Convert.ToDecimal(temp));
    

    works for me