I\'m trying to write a validation to check that an Object instance can be cast to a variable Type. I have a Type instance for the type of object they need to provide. But th
MyObject myObject = new MyObject();
Type type = myObject.GetType();
if(typeof(YourBaseObject).IsAssignableFrom(type))
{
//Do your casting.
YourBaseObject baseobject = (YourBaseObject)myObject;
}
This tells you if that object can be casted to that certain type.