C#: Get key and value types of non-generic IDictionary at runtime
- by Yang Zou
there.
I am wondering how I can get the key and value types of a non-generic IDictionary at runtime.
For generic IDictionary, we can use reflection to get the generic arguments, which has been answered here.
But for non-generic IDictionary, for instance, HybridDictionary, how can I get the key and value types? Thanks.
Edit: I may not describe my problem properly.
For non-generic IDictionary, if I have HyBridDictionary, which is declared as
HyBridDictionary dict = new HyBridDictionary();
dict.Add("foo" , 1);
dict.Add("bar", 2);
How can I find out the type of the key is string and type of the value is int?
Did I make the question clear?
Thanks.