while (true) { Console.WriteLine("请输入学生姓名"); string a = Console.ReadLine(); if (a == "q") { Console.WriteLine("结束"); break; } }
Console.WriteLine("请输入学生姓名"); string a = Console.ReadLine(); while (a != "q") { Console.WriteLine("请输入学生姓名"); a = Console.ReadLine(); } Console.WriteLine("请按任意键退出"); Console.ReadKey();