源代码:
using System;
class Method
{
static void Main()
{
string TempName="";
while(TempName!="end")
{
TempName=Console.ReadLine();
MyMethod(TempName);
}
}
public static void MyMethod(string AName)
{
Console.WriteLine("The name is "+AName+"\n");
}
}
疑问:为什么当输入"end"以后,屏幕还是打印"The name is end"才结束,而不是直接结束呢??
using System;
class Method
{
static void Main()
{
string TempName = Console.ReadLine();
while (TempName != "end")
{
MyMethod(TempName);
TempName= Console.ReadLine();
}
}
public static void MyMethod(string AName)
{
Console.WriteLine("The name is " + AName + "\n");
}
}
仔细看楼上的的
MyMethod(TempName);
TempName= Console.ReadLine();