In C# using VS2005, if I have a variable of type Object, to which I assign a MyObjectType object by casting as follows:
MyObjectType myObj = GetMyObject();
Object obj = (Object)myObj;
Is there way to determine that obj is actually a MyObjectType and not just an Object?
Absolutely:
Or, if you want to then use some members of it:
Note that these will work even if
objrefers to an object derived fromMyObjectType. If you only want an exact match, you should use:… but that’s a pretty rare use case in my experience.