Note that there are some explanatory texts on larger screens.

plurals
  1. POString to bool (a is true rest is false)
    text
    copied!<p>I was testing with c# and ran to a "little" problem. I searched the web for an hour but I found code that din't work :(</p> <p>I'm testing with c# and trying to make a little quiz in the command promt</p> <pre><code> //variables questions, Vraag is question, Solution is the solution, and Keuze is the three choices (a,b and c) string Vraag1 = ("Wat is de hoofstad van Oostenrijk?"); string Solution1 = ("Wenen"); string Keuze1 = ("a: Wenen b: Rome c: Kiev"); string Vraag2 = ("Hoe heet de hoogste berg van Afrika?"); string Solution2 = ("De Kilimanjaro"); string Keuze2 = ("a: De Mount-everest b: De Kilimanjaro c: De Aconcagua"); string Vraag3 = ("Wie was de uitvinder van de gloeilamp?"); string Solution3 = ("Edison"); string Keuze3 = ("a: Thomas Edison b: Albert Einstein c: Abraham Lincoln"); //Other variables //entered1, 2 and 3 are variables that the user typed in //code //Question 1 Console.WriteLine("Vraag 1:"); Console.WriteLine(); Console.WriteLine(Vraag1); Console.WriteLine(); Console.Read(); Console.WriteLine(Keuze1); Console.Read(); string entered1 = Console.ReadLine(); Boolean enteredbool1 = !entered1.Equals("a"); if (enteredbool1) { Console.ForegroundColor = (ConsoleColor.Green); Console.WriteLine("Goedzo, op naar de volgende!"); } else { Console.WriteLine("FOUT!"); } </code></pre> <p>My problem is that if the user answered "a" it says its good (goedzo) but if he typed b it gives the same result not wrong (fout).</p> <p>I think it has something to do with the conversion of the string to boolean. I tryd to remove the "!" but that gives reversed effects (only say's the question was wrong).</p> <p>I hope someone can help!</p> <p>Gijs</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload