输入空值没有效果,是哪出错了,请教各位大哥
using System;using System.Collections.Generic;
using System.Text;
namespace Project1
{
class Class1
{
static void Main()
{
bool myBool = false;
Console.WriteLine("请输入姓名");
Console.WriteLine("(1)张三(2)李四(3)王五");
int myName =Convert.ToInt32( Console.ReadLine().Trim());
Console.WriteLine("请输入密码");
string myPassword=Console.ReadLine().Trim();
do
{
switch(myName)
{
case 1:
if(myPassword=="123456")
{
Console.WriteLine("密码正确!");
}
else
{
Console.WriteLine("密码错误");
}
break;
case 2:
if(myPassword=="234567")
{
Console.WriteLine("密码正确!");
}
else
{
Console.WriteLine("密码错误");
}
break;
case 3:
if(myPassword=="345678")
{
Console.WriteLine("密码正确!");
}
else
{
Console.WriteLine("密码错误");
}
break;
default:
Console.WriteLine("查无此人");
break;
}
}
while(!myBool);
Console.WriteLine("没有输入有效姓名,系统将退出……\n按回车键退出程序!");
Console.ReadLine();
}
}
}