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