title: Using System.DateTime in a C# Lambda expression gives an exception
body: <p>I tried to implement a suggestion that came up in another question: <a href="https://stackoverflow.com/questions/8187322/how-can-i-use-a-html-helper-method-in-an-extension-method">Stackoverflow question</a></p>
  
  <p>Snippet here:</p>
  
  <pre><code> public static class StatusExtensions
      {
          public static IHtmlString StatusBox&lt;TModel&gt;(
              this HtmlHelper&lt;TModel&gt; helper,
              Expression&lt;Func&lt;TModel, RowInfo&gt;&gt; ex
          )
          {
              var createdEx =
                  Expression.Lambda&lt;Func&lt;TModel, DateTime&gt;&gt;(
                      Expression.Property(ex.Body, "Created"),
                      ex.Parameters
                  );
              var modifiedEx =
                  Expression.Lambda&lt;Func&lt;TModel, DateTime&gt;&gt;(
                      Expression.Property(ex.Body, "Modified"),
                      ex.Parameters
                  );
              var a = "a" + helper.HiddenFor(createdEx) +
                  helper.HiddenFor(modifiedEx);
              return new HtmlString(
                  "Some things here ..." +
                  helper.HiddenFor(createdEx) +
                  helper.HiddenFor(modifiedEx)
              );
          }
      }
  </code></pre>
  
  <p>When implemented I am getting the following exception which I don't really understand. The exception points to the line starting with "var createdEx ="</p>
  
  <pre><code>System.ArgumentException was unhandled by user code
    Message=Expression of type 'System.Nullable`1[System.DateTime]' cannot be used for return type 'System.DateTime'
    Source=System.Core
    StackTrace:
  </code></pre>
  
  <p>Can anyone help me out and suggest what I could do to resolve the exception?</p>