title: Grouping multiple conditions in IF statements C#
body: <p>I'm writing a program that needs to perform a search as one of the required functions. The user should be able to use any number of fields, ranging from none to all of them (total of 7). So far I've had success grouping each case of data input within an if statement like so:</p>
  
  <pre><code>List&lt;TypeClass&gt; myList = new List&lt;TypeClass&gt;
  
  foreach TypeClass currentItem in myList
  
  {
      if (data1 == currentItem.GetData1() || data1 == "Do Not Search" &amp;&amp; (data2 == currentItem.GetData2() || data2 == "Do Not Search") &amp;&amp; (data3...)
  
      {
          //Stuff
      }
  
  }
  </code></pre>
  
  <p>If you notice, I grouped each data field within brackets, so the statement can only be satisfied if each of the entered data is either the needed condition, or an 'empty field'. However, I can't group the very first portion of the statement as I do with the other data2,3,4... Instead the statement always gets evaluated to true even if there are other search fields that do not satisfy the conditions of the statement. If I use additional brackets the program completely ignores the if statement and treats it as if none of the cases match at all. </p>
  
  <p>So if I write it like this:</p>
  
  <pre><code>if ((data1 == currentIten.GetData1 || data1 == "Do Not Search") &amp;&amp; (data2...)
  </code></pre>
  
  <p>Nothing gets checked and the statement is ignored. Is this normal? Are there any better/more efficient ways of dealing with optional search field selection?</p>
  
  <p>EDIT: Sorry for the typo, each GetDataX is an accessor and I forgot to write the parentheses () </p>