mercredi 4 septembre 2019

C#: Converting unknown object to unknown type when object does not implement IConvertible

I have object o which has unknown type. I also have a type t to which I want to convert my object.

object o = GetExampleObject();
Type t = GetExampleType();

When I try to invoke:

Convert.Invoke(o, t);

I get error:

Object must implement IConvertible.

Is there any way to cast it?





Aucun commentaire:

Enregistrer un commentaire