Getting Console Input

2 replies [Last post]
Offline
Last seen: 48 weeks 3 days ago
Joined: 04/24/2010
Posts:

I have tried all of the following without success:
string text = Console.Readline()
string text = Console.Read()
How do I get input from the console? I have tried many tutorials and different ways(Console.In.Readline) and none of them work. Is there a specific reference or something that I need to declare?
Thanks

tim.speed's picture
Offline
Last seen: 18 hours 29 min ago
Joined: 02/24/2010
Posts:
Re:Getting Console Input

Can you post the code?
Here is some code I wrote that works:
 
using System;namespace Test{ class Program { static void Main(string[] args) { Console.WriteLine("Please write something."); string line = Console.ReadLine(); } }}

-----------------
Tim Speed
Compilr Developer and CTO

tim.speed's picture
Offline
Last seen: 18 hours 29 min ago
Joined: 02/24/2010
Posts:
Re:Getting Console Input

From a close look here, if this was exactly how the line was typed in the IDE, you are missing an ending semi-colon and the L in line needs to be capitalized as c# is a case-sensitive language.
string text = Console.Readline()would be:string text = Console.ReadLine();

-----------------
Tim Speed
Compilr Developer and CTO