title: Simplify case-if-else ladder in C# code
body: <p>EDIT: I am more interested in particular programming practice or way of coding to avoid this. But any suggestion is welcome.</p>
  
  <p>I have written this ugly looking code to perform certain tasks:</p>
  
  <pre><code>switch(arg[0])
  { 
      case "a"
      {
          foreach(var c in obja)
          {
              if(c.entry == 'a')
              {
                  if (Independent_condition_1)
                  {
                      // do logging
                      continue;
                  }
                  if (Independent_condition_2)
                  {
                      // do logging
                      continue;
                  }
                  // Do something if above two conditions are false
              }
              else
              {
                  if (Independent_condition_3)
                  {
                      // do logging
                      continue;
                  }
                  if (Independent_condition_4)
                  {
                      // do logging
                      continue;
                  }
                  // do something if above 2 conditions are false.
              }
          }
          break;
      }
      case "b"
      {
          // similar if else ladder
      }   
  }
  </code></pre>
  
  <p>Problem is the code looks ugly and is very unreadable. I've moved most of the things inside if-else to functions just to simplify the code. What's the alternative of such long nested if-else?</p>