+ 2

How do I fix name console doesn't exist in current context(c#)?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) {string hello; hello= console.readline(); if (hello == "hi") { Console.WriteLine("Hello, Dcoder!");} } } }

12th Jul 2020, 5:12 AM
Prajanay Vyas
Prajanay Vyas - avatar
7 Answers
+ 4
Prajanay Vyas try the following: //How do I fix name console doesn't exist in current context(c#)? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) {string hello; //Use this exactly on line 16 hello= Console.ReadLine(); //The rest is ok but need to add an else if (hello == "hi") //should add a conditional else otherwise No Output { Console.WriteLine("Hello, Dcoder!");} else { Console.WriteLine("Next time enter 'hi'");} } } }
12th Jul 2020, 5:37 AM
BroFar
BroFar - avatar
+ 3
Prajanay Vyas C# is case sensitive. You can't write Console to console and ReadLine to readline. You need to remember this.
12th Jul 2020, 5:32 AM
A͢J
A͢J - avatar
+ 2
Console.ReadLine capital letters!!!
12th Jul 2020, 5:17 AM
Андрей Митрахович
Андрей Митрахович - avatar
+ 2
Thank you so much everyone
12th Jul 2020, 5:44 AM
Prajanay Vyas
Prajanay Vyas - avatar
+ 2
It worked
12th Jul 2020, 5:44 AM
Prajanay Vyas
Prajanay Vyas - avatar
+ 1
Then it says console doesn't contain defination of readline
12th Jul 2020, 5:20 AM
Prajanay Vyas
Prajanay Vyas - avatar
+ 1
ReadLine() uppercase letter, too
12th Jul 2020, 5:33 AM
Андрей Митрахович
Андрей Митрахович - avatar