ThickBook ThickBook - 1 year ago 78
C# Question

C# beginner help

Can you help in this example? I am a beginner. I am trying to display name from keyboard in console windows.

class Program
public static void Main(string[] args)
Console.Write("Your Name?: ");
string name = Console.Read();
Console.WriteLine("Welcome {0}", name);

Jon Jon
Answer Source

Amongst other things, you probably want to change the middle line of the Main method to

string name = Console.ReadLine();

The Read method returns a single character, whereas the ReadLine method will return the whole line.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download