Console.WriteLine("Unlike my deceased predecessor, A.I./Ai, I do not mind not being human. I am content with what I have.");
Console.ReadKey();
bool AI = false;
if (AI = true)
我希望用户输入“AI”并将bool设置为true,如果他们这样做的话。
答案 0 :(得分:2)
阅读完所有评论后,我认为这就是你的意思
Console.WriteLine("Unlike my deceased predecessor, A.I./Ai, I do not mind not being human. I am content with what I have.");
string answer = Console.ReadLine();
bool AI = (answer == "AI");
答案 1 :(得分:2)
您想使用Console.ReadLine,而不是Console.ReadKey。如果用户输入Ai
或ai
,您还应该使检查大小写不敏感。
Console.WriteLine("Unlike my deceased predecessor, A.I./Ai, I do not mind not being human. I am content with what I have.");
string lineRead = Console.ReadLine();
bool AI = "ai".Equals(lineRead, StringComparison.OrdinalIgnoreCase);
if(AI)
{
// ai was selected
}