Search code examples
c#arrayscompiler-errorsdoublevisual-studio-2019

"System.FormatException: 'Input string was not in a correct format" error in arrays


hello guys this is my code:

        double[] milad = new double[5];
        for (int i = 0; i < milad.Length; i++)
        milad[i] = double.Parse(Console.ReadLine());

but when I input a float number like 25.5 compiler error me "System.FormatException: 'Input string was not in a correct format" can somebody help me?


Solution

  • Your code runs without errors, it may be that your input is incorrect.

    Do not use ',' instead of '.' .

    That's my Output:

    enter image description here

    Add your error in the comment below me, and I will give you suggestions.