I have a method that can return many types of objects (that's why it return just object).
How can I cast it to it's original type? (The question is about casting to it's original type, when I don't know it's type on run time. It is not about casting when I know it's type; that's why GetAnyObject
method is black box)
private void func()
{
var obj = GetAnyObject();
callFunc(obj);
}
private void callFunc(object o)
{
var a = o.GetType();
...
}
Aucun commentaire:
Enregistrer un commentaire