title: Why Task doesn't return null
body: <p>I'm working with the new <a href="http://msdn.microsoft.com/en-us/library/dd460717.aspx" rel="nofollow">Task Parallel Library</a> and today went to this case:</p>
  
  <p>This code doesn't compile:</p>
  
  <pre><code>    internal Task&lt;Guid?&gt; SavePages(string[] pages)
      {
          return Task.Run(() =&gt;
          {
              if (pages == null || pages.Length == 0)
                  return null;
  
              ....
  </code></pre>
  
  <p>Unless I explicitly returns a null nullable Guid:</p>
  
  <pre><code>    internal Task&lt;Guid?&gt; SavePages(string[] pages)
      {
          return Task.Run(() =&gt;
          {
              if (pages == null || pages.Length == 0)
                  return (Guid?)null;
  
              // Check documents path access
  </code></pre>
  
  <p>Why this behavior, I'm I doing something wrong? I mean, I get the code to work with the second option but don't know If I'm misusing the library, I mean, null is always null, isn't it?</p>
  
  <p>Compile error: </p>
  
  <blockquote>
    <p>Cannot convert lambda expression to delegate type
    'System.Func' because some of the return
    types in the block are not implicitly convertible to the delegate
    return type</p>
  </blockquote>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/dd460717.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd460717.aspx</a></p>