我是 C# 新手,我无法弄清楚这段代码有什么问题。我正在创建一个测验,如果答案是正确的,我试图说做得好,但它不断提出不能隐式地将类型字符串转换为类型 bool。
这是我的代码:
{
int score = 0;
Console.WriteLine(" What is your name?");
string name = "";
name = Console.ReadLine();
Console.WriteLine("Hello " +name+ " and welcome to the Formula 1 quiz.");
Console.ReadLine();
Console.WriteLine("Question 1: How many races has Michael Schumacher won.");
Console.ReadLine();
Console.WriteLine("a) 91");
Console.WriteLine("b) 51");
Console.WriteLine("c) 41");
Console.WriteLine("d) 31");
Console.ReadLine();
string answer = Console.ReadLine();
if (answer = a) Console.WriteLine("Well done");
else Console.WriteLine("Wrong answer");
}