0
What to do if a code has many switches?
Switches... switches... switches...
11 Answers
+ 10
Ternary operators, RegEx, multiple conditions, try-catch……
+ 9
Replace them with "if-else" ??
+ 8
Well…… are there any other options??
+ 6
Nothing that I can think of would make your code run faster. I guess it depends on the speed of the processor you have.
+ 6
There might be something else based on your specific situation, but it would for sure require changing other things in your code (probably adding another class or two)
I think you could just have another class and use a reference from their to do things, instead of having switches. But I'm not a c# programmer.
+ 1
i don't know for certain if it is possible, but perhaps a while-loop could do the job? a while loop that will return your cases for the switch?
0
but the code will do slowly?
0
I do not know ... the code has many switches and I do not know what would be better
0
Is there a way to decrease the number of switches?
0
thanks for help me ^^
0
The code is a virtual assistant that uses switches with strings to respond to commands. But now there are many commands and the code has many switches