<p>Could someone explain why this works in C#.NET 2.0:</p>

<pre><code>    Nullable&lt;DateTime&gt; foo;
    if (true)
        foo = null;
    else
        foo = new DateTime(0);
</code></pre>

<p>...but this doesn't:</p>

<pre><code>    Nullable&lt;DateTime&gt; foo;
    foo = true ? null : new DateTime(0);
</code></pre>

<p>The latter form gives me an compile error "Type of conditional expression cannot be determined because there is no implicit conversion between '&lt;null&gt;' and 'System.DateTime'."</p>

<p>Not that I can't use the former, but the second style is more consistent with the rest of my code.</p>

The compiler is telling you that it doesn't know how convert
```
null
```
into a
```
DateTime
```
.
The solution is simple:
```
```
DateTime? foo;
foo = true ? (DateTime?)null : new DateTime(0);
```
```
Note that
```
Nullable<DateTime>
```
can be written
```
DateTime?
```
which will save you a bunch of typing.