Getting Console Input
Fri, 05/14/2010 - 22:38
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
Tue, 05/18/2010 - 16:08
#2
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();
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