Console.ReadLine() doesn't execute? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Console.ReadLine() doesn't execute?

Hi, I compiled and ran the interactive hello world program, and it seems that it ignored my Console.ReadLine() call. Since it's so short, I'll copy it right here:

// project created on 5/10/2007 at 4:02 PM
using System;

namespace InteractiveHelloWorld
{
class MainClass
{
static void Main(string[] args)
{
Console.Write("Please enter your name: ");
string name = Console.ReadLine();
Console.WriteLine
("Hello {0}, Good Luck in C#", name);
}
}
}

it compiled without errors or warnings, but the output I got was:

Please enter your name: Hello , Good Luck in C#

Has anyone else tried this in MonoDevelop and/or had this problem?

Comments

  • excmanexcman Posts: 1Member
    : Hi, I compiled and ran the interactive hello world program, and it
    : seems that it ignored my Console.ReadLine() call. Since it's so
    : short, I'll copy it right here:
    :
    : // project created on 5/10/2007 at 4:02 PM
    : using System;
    :
    : namespace InteractiveHelloWorld
    : {
    : class MainClass
    : {
    : static void Main(string[] args)
    : {
    : Console.Write("Please enter your name: ");
    : string name = Console.ReadLine();
    : Console.WriteLine
    : ("Hello {0}, Good Luck in C#", name);
    : }
    : }
    : }
    :
    : it compiled without errors or warnings, but the output I got was:
    :
    : Please enter your name: Hello , Good Luck in C#
    :
    : Has anyone else tried this in MonoDevelop and/or had this problem?
    :



    I have the same problem, i tried writing an even simpler program and it is definatly the Console.ReadLine() part.
    It seems to ignore it and continues with the other lines.
    This is what i did:

    using System

    class Greeter
    {
    static void Main()
    {
    Console.Write("Enter your name : ");
    string name = Console.ReadLine();
    Console.WriteLine("Hello " + name );
    Console.WriteLine("Gosh you are handsome! ");
    }
    }

    Any help would be greatly appreciated.
  • mhvrharshamhvrharsha Posts: 1Member
    try with
    Dim name as string=Console.readline()
Sign In or Register to comment.