[Mono-list] Simple Console ReadLine problem

Jeffrey Stedfast fejj at novell.com
Fri Mar 28 16:04:51 EDT 2008


On Wed, 2008-03-26 at 12:13 -0700, radzfoto wrote:
> I am a moderately experienced programmer especially in C and C++. I am just
> learning C#.
> 
> I compiled the following under MS Visual Studio and it worked fine. However,
> exact same code fails to read the string using ReadLine. Any ideas that
> could help me out?
> 
> Here is the code:
> using System;
> 
> namespace TestReadLine
> {
> 	class MainClass
> 	{
> 		public static void Main(string[] args)
> 		{
> 			string str;
> 			
> 			Console.Write("Enter some text and press enter: ");
> 			str = Console.ReadLine();
> 			Console.WriteLine("This is the text you entered: " + str);
> 			Console.ReadLine

this line ^^^ needs to be changed to:

                          Console.ReadLine();

> 		}
> 	}
> }
> 
> Thanks!
> Radzfoto
> 

before making the change, I was not able to compile your test program,
so I assume you must have had the "();" in your original source.

That said, I wasn't able to reproduce your problem:

[fejj at tazmanian-devil src]$ gmcs readln.cs 
[fejj at tazmanian-devil src]$ mono ./readln.exe 
Enter some text and press enter: sdffasfasfasfasf
This is the text you entered: sdffasfasfasfasf

In case you were maybe using mcs instead of gmcs, I tried again:

[fejj at tazmanian-devil src]$ mcs readln.cs 
[fejj at tazmanian-devil src]$ mono ./readln.exe 
Enter some text and press enter: asfasdasdasdas
This is the text you entered: asfasdasdasdas


Can you explain your problem a bit more?

Jeff




More information about the Mono-list mailing list