我希望用户输入他的名字并得到控制台的欢迎。无法弄清楚我在这里做错了什么...
编辑:好的,看起来Console.Read
是问题所在。不知道为什么。
using System;
namespace Program1
{
// use can use regions to wrap code in them and they can be collapsed
#region
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter ur name : "); // showing a msg to user
string name = Console.ReadLine(); // defining a string variable and getting input from user
Console.WriteLine("Hello " + name); // saying hi to user by adding his name that we asked earlier
Console.WriteLine("Press any key to terminate ...");
Console.Read;
}
#endregion // use can use regions to wrap code in them and they can be collapsed
}
}
您在 Console.Read 之后缺少一个括号,应如下所示Console.Read()