title: Generic null object pattern in C#
body: <p>I'm wondering if there is any approach to implement generic null object pattern in C#. The generic null object is the subclass of all the reference types, just like <code>Nothing</code> in Scala. It seems like</p>
  
  <pre><code>public class Nothing&lt;T&gt; : T where T : class
  </code></pre>
  
  <p>But it can't compile and I've no idea <strong>how to implement the methods of <code>T</code> to provide default behavior or throw an exception</strong>. Here are some thinkings:</p>
  
  <ol>
  <li>Use reflection?</li>
  <li>Use expression tree when creating <code>Nothing&lt;T&gt;</code>? It maybe looks like Moq. And another question comes: Is it OK to use mock framework/library in product codes?</li>
  <li>Use dynamic types?</li>
  </ol>
  
  <p>I KNOW maybe I should implement particular null object for particular type. I'm just curious to know if there is any solution.</p>
  
  <p>Any suggestion? Thanks.</p>