difference between ME and MYCLASS
- From: "Radu" <REMOVETHISPARTcuca_macaii2000@xxxxxxxxx>
- Date: Fri, 10 Mar 2006 01:23:44 -0500
Hi. I have the following question:
Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in the
context of Child.
-------------------------------
Module Module1
Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub
End Module
-------------------------------
Public Class Parent
Public Sub DoSomething()
OtherStuff()
End Sub
Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub
End Class
-------------------------------
Public Class Child
Inherits Parent
Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub
End Class
----------------------------------
Therefore, to avoid this, we have to change parent using MYCLASS....
-------------------------------
Public Class Parent
Public Sub DoSomething()
MyClass.OtherStuff()
End Sub
Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub
End Class
-------------------------------
I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?
Thank you.
Alex.
.
- Follow-Ups:
- Re: difference between ME and MYCLASS
- From: Larry Lard
- Re: difference between ME and MYCLASS
- From: Cor Ligthert [MVP]
- Re: difference between ME and MYCLASS
- Prev by Date: Re: Collections challenge (MRU)
- Next by Date: Re: How select from 2 ADO.NET DataTables?
- Previous by thread: How select from 2 ADO.NET DataTables?
- Next by thread: Re: difference between ME and MYCLASS
- Index(es):
Relevant Pages
|