difference between shadowing and method overriding in VB.net

Posted by Jameschowdare under ASP.NET on 5/13/2009 | Views : 8385 | Status : [Member] | Replies : 2
difference between shadowing and method overriding in VB.net




Responses

Posted by: Vuyiswamb on: 5/13/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Afternoon Jameschowdare

Shadowing :- This is a VB.Net Concept by which you can provide a new implementation for the base class member without overriding the member. You can shadow a base class member in the derived class by using the keyword Shadows . The method signature access level and return type of the shadowed member can be completely different than the base class member.

Hiding : - This is a C# Concept by which you can provide a new implementation for the base class member without overriding the member. You can hide a base class member in the derived class by using the keyword new . The method signature access level and return type of the hidden member has to be same as the base class member.Comparing the three :-

1) The access level signature and the return type can only be changed when you are shadowing with VB.NET. Hiding and overriding demands the these parameters as same.

2) The difference lies when you call the derived class object with a base class variable.In class of overriding although you assign a derived class object to base class variable it will call the derived class function. In case of shadowing or hiding the base class function will be called.

for more info check here
http://msdn.microsoft.com/en-us/library/ms172785.aspx

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Syedshakeer on: 5/17/2009 [Member] Starter

Up
0
Down
Hi

Overriding redefines only the implementation while shadowing redefines the whole element.On the other side In overriding derived classes can refer the parent class element by using "ME " keyword, but in shadowing you can access it by "MYBASE ".



Syed Shakeer Hussain

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response