Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.