Convert.Toint32(Console.ReadLine()) does not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Convert.Toint32(Console.ReadLine()) does not working

showing that it doesn't exists

5th Jul 2016, 4:56 AM
Shadab Khan
Shadab Khan - avatar
5 Answers
+ 1
Do you have it like this? int test; test = Convert.ToInt32(Console.ReadLine()); And don't forget that C# is case sensitive.
5th Jul 2016, 5:00 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
0
namespace SoloLearn { class Program de { int a,b,c; void add() { Console.WriteLine("input the 1st value"); a=Convert.ToInt32(Console.ReadLine()); Console.WriteLine("input the 2nd value"); b=Convert.ToInt32(Console.ReadLine()); c =a*b; Console.WriteLine("result ="+ c); } static void Main(string[] args) { Program q= new Program(); q.add(); Console.ReadLine(); } } } showing an unhanded exception
5th Jul 2016, 12:12 PM
Shadab Khan
Shadab Khan - avatar
0
int.TryParse(Console.ReadLine(), out a); would prevent the program from (sometimes) crashing when the user inputs a non-integer value.
6th Aug 2016, 1:12 PM
Samuel Neo
Samuel Neo - avatar
- 1
this code just don't ask for the second input
5th Jul 2016, 9:22 AM
Yulia Kuznechenkova
Yulia  Kuznechenkova - avatar
- 1
I'll show you
5th Jul 2016, 12:03 PM
Shadab Khan
Shadab Khan - avatar