title: How to define a boolean expression and evaluate it only when used?
body: <p>Let's go straight to an example:</p>
  
  <pre><code>public bool MeetsAllConditions()
  {
      bool check1, check2, check3;
  
      // Some code to define result of check1
      if (something...)
      {
          if (something...)
          {
              check1 = true;
          }
      }
  
      // many more code to define check2 and check3
      ....
  
      if (check1 &amp;&amp; check2 &amp;&amp; check3)
      {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>Now, the code to define each <code>check</code> is very <strong>expensive</strong>. Hence I would like to make it so that the code that defines result of each check is evaluated <strong>only</strong> <strong>in</strong> <strong>the final</strong> <code>if</code> statement. This way I can utilise lazy evaluation to save resource if <strong>any</strong> of the check <strong>fails</strong>.</p>
  
  <p>How would I approach this <strong>without defining a separate method</strong> for each <code>check</code> in C#?</p>