Roland,
| Public Shared Function Load() As Object
Ah! There's the rub!
The Load method is Shared, meaning it is part of the Shoe class, and not
inherited by the Sandal class per se.
Although VB allows you to code:
Sandal.Load()
It calls Shoe.Load directly in the IL, which means that Shoe.Load will never
know you attempted to call it on the Sandal class.
| So, my question is: Is it possible to find out the type/class which was
| actually called from within the base class?
If Load was an instance method (not shared) you could use Me.GetType within
it to get the actual type of the object (the derived type).
Seeing as Load is a shared method, there is no such method sans passing a
parameter.
I would consider:
1) making the Load method Generic
2) passing a Type parameter
3) adding Load to each derived type, instead of in the base class
4) create Shoe & Sandal Factory classes that allow polymorphism via
inheritance...
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
<ro*********@gmail.com> wrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
| Hi,
|
| Here is the basic setup, my base class is Shoe which has a child class
| called Sandal. I would like to create objects by calling Sandal.Load.
| But without overloading Load in Sandal and sending the Sandal type to
| the base class I can not instantiate a Sandal class from within Shoe.
|
| Public Class Shoe
| Public Shared Function Load() As Object
| return ?????
| End Function
| End Class
|
| Public Class Sandal
| Inherits Shoe
| End Class
|
| Public Class MyShoeBox
| Private mySandal as Sandal = Sandal.Load()
| End Class
|
| So, my question is: Is it possible to find out the type/class which was
| actually called from within the base class?
|
| Kind regards,
| Roland
|