title: Lazy Evaluation not so Lazy?
body: <p>I've always heard C# uses lazy evaluation.  So for certain code like, <code>if (true || DoExpensiveOperation()</code> will return <code>true</code> without executing <code>DoExpensiveOperation()</code>.</p>
  
  <p>On an interview test I saw the following questions,</p>
  
  <pre><code>static bool WriteIfTrue(bool argument)
  {
      if (argument)
      {
          Console.WriteLine("argument is true!");
      }
  
      return argument;
  }
  
  static void Main()
  {
      // 1              0                       0                 1
      WriteIfTrue((WriteIfTrue(false) &amp; WriteIfTrue(true)) || WriteIfTrue(true));
  
      // 1               1                     0                      1
      WriteIfTrue((WriteIfTrue(true) || WriteIfTrue(false)) &amp; WriteIfTrue(true));
  
      //  0                 0                  0                    0
      WriteIfTrue((WriteIfTrue(false) &amp; WriteIfTrue(true)) &amp; WriteIfTrue(false));
  
      // 1                1                      0                   1
      WriteIfTrue((WriteIfTrue(true) || WriteIfTrue(false)) &amp; WriteIfTrue(true));
  }
  </code></pre>
  
  <p>How many times would it print "argument is true!" to the screen?</p>
  
  <p>I would say <code>7</code> is the correct answer.  Now if I stick into the compiler and run it, it prints it <code>10</code> times!  Where did lazy evaluation all go wrong?</p>