title: Is there a difference between a ternary operator and an if statement in C#?
body: <p>I'm working with a nullable DateTime object and ran into some strange behavior.  Here's a sample function:</p>
  
  <pre><code>    public DateTime? Weird()
      {
          DateTime check = DateTime.Now;
          DateTime? dt;
          if (check == DateTime.MinValue)
              dt = null;
          else
              dt = Viewer.ActiveThroughUTC.ToLocalTime();
  
          //this line give a compile error
          dt = (check == DateTime.MinValue) ? (null) : (Viewer.ActiveThroughUTC.ToLocalTime());
          return dt;
      }
  </code></pre>
  
  <p>As far as I know, the line with the ternary operator should be the same as the preceding four lines, but VS2010 is giving me a compile error, saying that no conversion exists between <code>&lt;null&gt;</code> and DateTime (even though the object in question is a 'DateTime?').  Is there something I should know about the ternary operator or is this (gasp?) a bug?</p>