title: Convert unknown KeyValuePair object to KeyValuePair<object, object>
body: <p>I have an object that is of type <code>KeyValuePair&lt;T1,T2&gt;</code> , but the actual types of <code>T1,T2</code> are only known at run time. I would like to extract <code>Key</code> and <code>Value</code> of that object but I do not know how. Could you please help? (The idea is as below but it does not work)</p>
  
  <pre><code>public override IDictionary&lt;string, object&gt; Serialize(object obj, JavaScriptSerializer serializer) {
       KeyValuePair&lt;object, object&gt; kvp = (KeyValuePair&lt;object, object&gt;)obj;
       Console.WriteLine("[{0},{1}]", kvp.Key, kvp.Value);
  }
  </code></pre>