K
Krishnan
Hi,
Just curious to know if there's a keyword equivalent to "Myclass" in VB.Net
in C#
TIA
Krishnan
Just curious to know if there's a keyword equivalent to "Myclass" in VB.Net
in C#
TIA
Krishnan
Krishnan said:Hi Harvey,
Thanks for your reply. Am sorry, but, I don't believe that to be the case. I
have tried to explain this with an example:
[VB.Net code]
Module Module1
Sub Main()
Dim b As Base
b = New Derived1
b.Test()
End Sub
End Module
Class Base
Public Sub Test()
Me.Foo()
MyClass.Foo()
End Sub
Public Overridable Sub Foo()
Console.WriteLine("Base - Foo")
End Sub
End Class
Class Derived1
Inherits Base
Public Overrides Sub Foo()
Console.WriteLine("Derived1 - Foo")
End Sub
End Class
Output:
=====
Derived1 - Foo
Base - Foo
In other words, MyClass makes the call to the function always on the "same"
class ireespective of the inheritance chain, wihle the rule in inheritance
is to call the "most" derived form of the method(as is done by the line
Me.Foo(). Please let me know if you think that this scenario can be
simulated in C#, and if so how. I'd be grateful if you can post your code
snippet here.
TIA
Krishnan
Harvey Green said:I think its 'base'
Me == this
MyClass == base
Klaus Löffelmann said:Krishian,
There is no equivalent to it in c#.
Klaus
case.Krishnan said:Hi Harvey,
Thanks for your reply. Am sorry, but, I don't believe that to be theI
have tried to explain this with an example:
[VB.Net code]
Module Module1
Sub Main()
Dim b As Base
b = New Derived1
b.Test()
End Sub
End Module
Class Base
Public Sub Test()
Me.Foo()
MyClass.Foo()
End Sub
Public Overridable Sub Foo()
Console.WriteLine("Base - Foo")
End Sub
End Class
Class Derived1
Inherits Base
Public Overrides Sub Foo()
Console.WriteLine("Derived1 - Foo")
End Sub
End Class
Output:
=====
Derived1 - Foo
Base - Foo
In other words, MyClass makes the call to the function always on the "same"
class ireespective of the inheritance chain, wihle the rule in inheritance
is to call the "most" derived form of the method(as is done by the line
Me.Foo(). Please let me know if you think that this scenario can be
simulated in C#, and if so how. I'd be grateful if you can post your code
snippet here.
TIA
Krishnan
Harvey Green said:I think its 'base'
Me == this
MyClass == base
Krishnan wrote:
Hi,
Just curious to know if there's a keyword equivalent to "Myclass" in VB.Net
in C#
TIA
Krishnan
* "Krishnan said:Just curious to know if there's a keyword equivalent to "Myclass" in VB.Net
in C#
* Harvey Green said:Me == this
MyClass == base
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.