C# Cannot implicitly convert type 'string' to 'bool' error -
i'm new c# i'm using microsoft visual studio express 2013 windows desktop edition , trying make quiz in ask question , user has answer so, here's code , error "cannot implicitly convert type 'string' 'bool'" , happens on 2 if statements, understand bool has either value true or false it's string why giving me error? should appreciated. ps: included part of code in i'm having problem , code in main class
heres code:
start: console.writeline(); console.writeline(); console.writeline("question 1: test? type yes or no: "); string answer1 = console.readline(); if (answer1 = "yes") { console.writeline(); console.writeline("question 2: test? type yes or no"); } else if (answer1 = "no") { console.writeline(); console.writeline("wrong, restarting program"); goto start; } else { console.writeline(); console.writeline("error"); goto start; }
in of if statements
if (answer1 = "yes")
should be
if (answer1 == "yes")
in c#, =
assign value, ==
comparison. change in of if statements , youll fine
Comments
Post a Comment