Equivalent C# keyword

  • Thread starter Thread starter Krishnan
  • Start date Start date
K

Krishnan

Hi,
Just curious to know if there's a keyword equivalent to "Myclass" in VB.Net
in C#

TIA
Krishnan
 
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
 
Krishian,

There is no equivalent to it in c#.

Klaus



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
 
Thanks Klaus & Miha.

Krishnan

Klaus Löffelmann said:
Krishian,

There is no equivalent to it in c#.

Klaus



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


Krishnan wrote:
Hi,
Just curious to know if there's a keyword equivalent to "Myclass" in VB.Net
in C#

TIA
Krishnan
 
Back
Top