Problem with switch-case

Hi guys, I'm a complete beginner in c# and a very bad programmer in general, so maybe this question is terribly elementary. please bear with me for a second; I have a problem with switch-case. I'm writing a console program which gives you a certain randomly generated problem to solve, then wants an answer.

my first "pseudocode" idea was something like this

switch (choice) case (choice == solution): print ok you're good. case (choice != solution): try again case "d": display solution 

this to avoid writing 2 functions, or to start nesting ifs and stuff. truth is, choice == solution is a bool. case solution is not accepted cause "solution" is not constant. const string solution2 = solution is not accepted. is there any way to trick switch-case or should I resign and start making nested ifs-call more methods?

thanks in advance

by jimeno via /r/csharp

Leave a Reply