0

Is it a bad habbit to have too many if-else statement in my code?

I'm a coding noob in C#, I just found I've used too many if-else statements in my code. The readability of the code is so bad. Is there a way to avoid using the if-else statement while maintaining readability?

29th Jun 2022, 12:23 AM
Yasswecancn
Yasswecancn - avatar
3 Antworten
+ 2
If you feel you have too many, you can always use something called a switch-statement. Here's a good source for how to use them in C#: https://www.geeksforgeeks.org/switch-statement-in-c-sharp/
29th Jun 2022, 12:58 AM
Justice
Justice - avatar
+ 2
Share your code bit link so people can review it to see, whether it is as you said - has too many branches. https://www.sololearn.com/post/75089/?ref=app
29th Jun 2022, 1:08 AM
Ipang
+ 2
Yasswecancn Switch statement is an alternative solution of multiple if else condition. And it will be more readable than multiple if else
29th Jun 2022, 5:54 AM
A͢J
A͢J - avatar