mardi 31 janvier 2017

Cast object to class in a referenced DLL

I have a assembly referenced which is custom assembly

For example Test.Contracts

Now, I have following method.

private void GetData(object data)
{

}

What i am looking to do here, is it possible to cast this object dyanamically using reflection to a class in referenced Assembly.

Remember the parameter is generic, and i will not know, which class i want to cast it to. For example I have two classes in the referenced assembly Class1,Class2

depending on the structure of the generic parameter "data" , it needs to be casted either as object of Class1 or Class2.





Aucun commentaire:

Enregistrer un commentaire