+ 1
How to convert String into Int
static void Main(string[] args) { int a; Console.WriteLine("Enter a number"); a=Console.ReadLine(); if(a==100) { Console.WriteLine("Perfect"); if(a>=50) { Console.WriteLine("Passed"); } } else { Console.WriteLine("Failed"); }
2 Respostas
+ 3
You cannot directly assign string to int. You need to convert it using the methods in the Convert class.
Thus, line 5 becomes :
a=Convert.ToInt32(Console.ReadLine());
Secondly, please tag your threads appropriately.