title: C#: How to remove all null properties from a generic object using reflection?
body: <p>I want to remove all null properties in a generic object. It doesn't have to be recursive, one level deep is also fine.</p>
  
  <p>The reason I need is for a custom JavascriptConvertor implementation for JSON serialization which gives me: {"Name":"Aleem", "Age":null, "Type":"Employee"}</p>
  
  <p>And I would like to skip over the null object.</p>
  
  <p>The function for this task takes in the objct and returns a Dictionary:</p>
  
  <pre><code>IDictionary&lt;string, object&gt; Serialize(object obj, JavaScriptSerializer serializer)
  </code></pre>
  
  <p>So I would like to remove all null properties from obj. All properties have getter but if the property is not set, the getter returns <code>null</code>.</p>