![]() |
|
[C#] Switch Case issue. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Switch Case issue. (/showthread.php?tid=5061405) |
Switch Case issue. - MrJamieMcC - Nov 17, 2015 So this is the code Code int caseSwitch = 1;I want all cases to display and then the user choses one. But currently, depending on the "int caseSwitch" number thats the only switch that is displayed. Thanks for the help :) EDIT: This is what i mean Spoiler (Click to View) I want all of the options to display not just the first * - +Haze - Nov 17, 2015 Can you re-phrase what you said. It doesn't make any sense. * - Odus - Nov 17, 2015 Move your WriteLine statements above the entire switch block, so they'll be printed regardless. Remember sequencing and selection. * - BahNahNah - Nov 17, 2015 You cant do that with a switch statement. You could do something like this. Code Dictionary<string, Tuple<string, Action>> options = new Dictionary<string, Tuple<string, Action>>* - Mouse❤️ - Nov 17, 2015 (Nov 17, 2015 01:53 PM)BahNahNah Wrote: You cant do that with a switch statement.Overly complicated way of doing exactly what Odus said, which is the answer to what the OP actually needs. Just move the output ... * - MrJamieMcC - Nov 17, 2015 Ive updated the post guys * - Mouse❤️ - Nov 17, 2015 (Nov 17, 2015 01:59 PM)MrJamieMcC Wrote: Ive updated the post guysBroken image. * - BahNahNah - Nov 17, 2015 (Nov 17, 2015 01:59 PM)MrJamieMcC Wrote: Ive updated the post guys Why are you even using a switch statement then 0_o. * - Mouse❤️ - Nov 17, 2015 The reason he's using a switch statement is because he wants a person to be able to enter a value, and then the program react, which is correct, but he for some reason can't read the response that this person posted: (Nov 17, 2015 01:53 PM)Odus Wrote: Move your WriteLine statements above the entire switch block, so they'll be printed regardless. Remember sequencing and selection.The answer's right there. * - MrJamieMcC - Nov 17, 2015 (Nov 17, 2015 02:03 PM)Μouse Wrote: The reason he's using a switch statement is because he wants a person to be able to enter a value, and then the program react, which is correct, but he for some reason can't read the response that this person posted: You mean like this? Spoiler (Click to View) I still got that issue. I apologise for being idiotic, ive just started learning * - BahNahNah - Nov 17, 2015 (Nov 17, 2015 02:07 PM)MrJamieMcC Wrote: You mean like this? Spoiler (Click to View) Remove the conosole writelines from the switch statement. * - Odus - Nov 17, 2015 (Nov 17, 2015 02:07 PM)MrJamieMcC Wrote: You mean like this? Spoiler (Click to View) Almost. You can remove them from the cases. Mouse saved me the hard work. P.S You can just call WriteLine without any args to terminate the line. Or append "\n" to your string literal. * - MrJamieMcC - Nov 17, 2015 Thank you all very much. I got it to work :) |