|
-
Jun 26th, 2010, 06:14 PM
#1
Thread Starter
New Member
Casting Subclasses, Base classes
I am a VB6 programmer learning VB.Net and am having trouble with the following concept.
I have two classes
Base class: Person
Subclass: Employee
Dim obj As Person = New Employee()
In simple terms, what is happening in memory (stack, heap)
When I try to do this:
Dim obj As Employee = New Person()
I get a cast error at runtime.
Why is that?
Is it illegal to cast from a subclass to a base class?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|