I am currently struggling with about 5 nested if statements, and it is becoming quite confusing to look at all of them.
So, I was thinking of adding ternary operators instead of ifs for simple checks, see
foreach (String control in controls)
{
if (!control.Equals(String.Empty))
{
foreach (Int32 someStuff in moreStuff)
{
if (!someStuff.Equals(0))
{
}
}
}
Here's what it looks like now. Thats my idea on how to make it look a little nicer:
foreach (String control in controls)
{
(control.Equals(String.Empty)) ? continue : null;
foreach (Int32 someStuff in moreStuff)
{
(someStuff.Equals(0)) ? continue : null;
}
}
So the questions are: 1. Poor programming to solve it this way and 2. Will it work the way I want?
source
share