【发布时间】:2022-01-25 21:15:03
【问题描述】:
在编程方面我是个初学者,所以对于这里的大多数人来说,我的问题可能看起来很容易。我正在尝试制作一个简单的程序,您可以在其中写下一周中的某一天,它应该根据答案显示信息。我选择星期天作为正确答案。我用 bool 和 string 进行了尝试,但我遇到了一个问题,它没有转换答案,所以我真的不知道下一步该做什么。 这是代码。
Boolean day;
Boolean Sunday = true;
Boolean Monday, Tuesday, Wednesday, Thursday, Friday, Saturday = false;
Console.Write("What's the day of the week today? Write your answer here: ");
day = Boolean.Parse(Console.ReadLine());
if (Sunday == true)
{
Console.WriteLine("Your answer is correct!");
}
else
{
Console.WriteLine("Your answer is incorret. Please try again.");
}
Console.ReadKey();
【问题讨论】:
-
C# 无法将输入的字符串链接到某个变量的名称