+ 1

C# help

Hi everyone. I’ m trying to remix a calculator in C# and I use this script : float number1 = Console.ReadLine(); float number2 = Console.ReadLine(); Console.WriteLine(number1 + number2); But the console say an error

10th Apr 2019, 7:10 AM
Tom
Tom - avatar
2 ответов
+ 5
Just some examples from Code Playground, you can search there for more examples to learn from 👍 https://code.sololearn.com/cPmnEkC8OWqz/?ref=app https://code.sololearn.com/cj9k3AxV1xau/?ref=app
10th Apr 2019, 7:35 AM
Ipang
+ 2
Console.ReadLine(); returns a string. You cannot assign a string to a float. You need to convert that number with float number1 = float.Parse(Console.ReadLine()); Be carefull some people use , (comma) as decimal separator other use . (dot) as decimal separator
10th Apr 2019, 7:30 AM
sneeze
sneeze - avatar