Basically, I have a parent class called "Roll" and I have two child classes that inherit from it, lets call them "type1" and "type2". Now, according to what I remember from the inheritance idea is that the child classes have an "is a" relationship to the parent (i.e. type1 is a roll, type2 is a roll). What I am trying to do is determine whether the specific instance is a type1 or a type2 and return the correct version. Something like this (although I already know this doesnt work):
Private Function GetInfo(Byval id as String) as Roll Dim type as Integer = GetTheType(id) If type = 1 then GetInfo = New Type1(id) ElseIf type = 2 then GetInfo = New Type2(id) Else 'the id doesnt exist GetInfo = Nothing End Function
Thats the basic idea. Any help would be much appreciated.
EDIT: Holy Christ I'm an idiot...that code does work, I just forgot to add the Inherits part of the code when creating all my classes /facepalm
This post has been edited by Psyguy: 31 January 2012 - 05:17 PM