title: c# Ternary operator returning different types
body: <p>I'm trying to use the ternary to return differing types, although I seem to be encountering some problems.  My question is can the ternary operator not return differing types?</p>
  
  <pre><code>// This line causes an error
  propertyGrid.Instance = (directoryRecord.directoryInfo != null) 
      ? directoryRecord.directoryInfo 
      : directoryRecord.fileInfo;
  
  // Compiles fine
  propertyGrid.Instance = directoryRecord.directoryInfo;
  
  // Compiles fine
  propertyGrid.Instance = directoryRecord.fileInfo;
  </code></pre>
  
  <p>Error</p>
  
  <blockquote>
    <p>Type of conditional expression cannot be determined because there is
    no implicit conversion between 'System.IO.DirectoryInfo' and
    'System.IO.FileInfo'</p>
  </blockquote>