When two programming elements share the same name, one of them can hide, or shadow, the other one. In such a situation, the shadowed element is not available for reference; instead, when your code uses the shared name, the Visual Basic compiler resolves it to the shadowing element.Reju
Login to rate this answer.
Shadowing is either through scope or through inheritance.
Shadowing through inheritance is hiding a method of a base class and providing a new implementation for the same. This is the default when a derived class writes an implementation of a method of base class which is not declared as overridable in the base class. This also serves the purpose of protecting an implementation of a new method against subsequent addition of a method with the same name in the base class.
'shadows' keyword is recommended although not necessary since it is the default.
Login to rate this answer.
while surfing i got very accurate and valid defination.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.http://www.codeproject.com/useritems/OSH.asp
Login to rate this answer.
Rituparno
Answered On : Jul 1st, 2006
| Criterion | Shadowing | Overriding |
|---|
| Purpose | Protecting against a subsequent base class modification introducing a member you have already defined in your derived class | Achieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence |
| Redefined element | Any declared element type | Only a procedure (Function or Sub) or property |
| Redefining element | Any declared element type | Only a procedure or property with the identical calling sequence1 |
| Accessibility | Any accessibility | Cannot expand the accessibility of overridden element (for example, cannot override Protected with Public) |
| Readability and writability | Any combination | Cannot change readability or writability of overridden property |
| Keyword usage | Shadows recommended in derived class; Shadows assumed if neither Shadows nor Overrides specified | Overridable required in base class; Overrides required in derived class |
| Inheritance of redefining element by classes deriving from your derived class | Shadowing element inherited by further derived classes; shadowed element still hidden2 | Overriding element inherited by further derived classes; overridden |
Login to rate this answer.
hari krishna
Answered On : Dec 11th, 2006
The programming techniuqe of replacing a member of a base class with a new member in a derived class.Shadowing differs from overriding in that base class's shadowed member is no longer available from the derived class
Login to rate this answer.
Gaurav
Answered On : Jul 16th, 2011
Shadowing is a concept of polymorphism usage in Object Oriented Programming. This is a concept related to over-riding functions at run-time or making a shadow of the object's methods in the inherited classes. Though it is not much used in programming but it may be used sometimes and its usage is very restrictive and unique.
Login to rate this answer.