0
Whats wrong with my code?
using System; using System.IO; using System.Linq; using System.Collections.Generic; namespace CSharp_Shell { public static class Program { public static void Main(string[]args) { Console.WriteLine("Enter your age"); int a; a= Console.ReadLine(); if(a<18){ Console.WriteLine("Not permitted"); }} } }
4 RĂ©ponses
+ 2
You need to convert Console.ReadLine() to int with Int32.Parse(). Becomes Int32.Parse(Console.ReadLine())
0
Why to convert?
0
It worked. Thanks.
0
It also wirks by this method...
a= int.Parse(Console.ReadLine());