atmosphere1212 Posted September 24, 2004 Posted September 24, 2004 Is it possible to cast down to an object that doesnt exist? ie temp = (SomeClass)objInstance where objInstance is an instance of a parent object, and SomeClass is the object I want. Note that objInstance is not an instance of SomeClass, just its parent Quote
Administrators PlausiblyDamp Posted September 24, 2004 Administrators Posted September 24, 2004 Is it possible to cast down to an object that doesnt exist? ie temp = (SomeClass)objInstance where objInstance is an instance of a parent object, and SomeClass is the object I want. Note that objInstance is not an instance of SomeClass, just its parent If temp is declared as the parent object then yes, you can make it equal to a sub-class. In fact you can always implicitly cast to a base class i.e. you don't even need the (...) bit. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.