ThickBook ThickBook - 8 months ago 51
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

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.