title: Boolean operations Optimization
body: <p>I had a tool that generated several Boolean values, something that looks like this:</p>
  
  <pre><code>(!(dcn.XdbDate != null)) &amp;&amp; (dcn.XdaDate != null)
  </code></pre>
  
  <p>The longest is 1361 characters long. I need to copy these over to C# source files to be used in linq queries.</p>
  
  <p>My question is first, does C# automatically optimize these operators? In the above example, would it be automatically converted to the below when compiled?</p>
  
  <pre><code>dcn.XdbDate == null &amp;&amp; dcn.XdaDate != null
  </code></pre>
  
  <p>If not, is there some C# compiler features where I can write a program, feed it the non-optimized ones and get optimized ones?</p>
  
  <p>Edit:</p>
  
  <p>Most of the generated Boolean operations are in the form of </p>
  
  <pre><code>xxx1 = condition ? value11 : value12,
  xxx2 = condition ? value21 : value22,
  etc...
  </code></pre>
  
  <p>The problem is with the <code>condition</code> part being not optimized.</p>