sebt
❔ In need of a way to process inputs to produce outputs, other than using hardcoded if statements
Hi all,
I currently have a program that prompts the user to ask a question, then based on the parameters in the user's input, my code will output the answer to said question. However, as of right now I have it so my code is just using a lot of if statements and structured in a way which is
and I essentially have it all hardcoded for each input however this takes up so many lines of code so I was wondering if anybody could help me find a more efficient way of carrying out this process.
479 replies
❔ C# Arrays/Switch case help
Hi guys,
I was just wondering if anybody here would be willing to potentially message me or hop in a voice call if they know a solution to my issue.
The issue is as follows:
Basically, I currently have a menu system that asks the user for an input, I then have a 2D array consisting of information that will be displayed depending on the user's input,
However, I am currently using a switch case like case "1" do this, case "2" do that, and this approach is for 8 different scenarios and thus is around 160lines long of just repeated console.writeline jargon. Since the user input is equal to one of the elements of the array, I was wondering if there was a shorter way of writing this so that my code would detect the user input, match that to its corresponding element in the array, and then print every element of said array.
If anybody could think of a solution and help me I would seriously appreciate it.
284 replies