jeudi 26 septembre 2019

How to get value from a KeyValuePair<> with unknown type

I have an object that is a KeyValuePair<> whose types I do not know. I need to get the Value of this KeyValuePair as object.

object kvpair = ... ;         // This is a KeyValuePair<K, V> with unknown K and V.
object value = kvpair.Value;  // I want to get the value of the kvpair

I understand this will involve using reflection.





Aucun commentaire:

Enregistrer un commentaire