Answer the question
In order to leave comments, you need to log in
The input string was not in the correct format. FormatException C# How to fix?
The code seems to be correct, but when I run it, it gives out "The input string had an incorrect format."
The code:
static void Main(string[] args)
{
string x; // Auxiliary variables
double t, s = 1;
Console.WriteLine("Enter the numbers one per line");
Console.WriteLine(" End – Ctrl + z");
while ((x = Console.ReadLine()) != null)
{ // End of circle
t = Convert.ToDouble(x); //(ругается на эту строку)
// Repeat steps
s *= t;
}
Console.WriteLine("The product of numbers is {0}", s); // Result
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question