GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 207 of 255    Print  
what is shadowing in .net?

  
Total Answers and Comments: 5 Last Update: December 12, 2006     Asked by: raja2020_it 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 19, 2005 00:04:38   #1  
rejumgeorge Member Since: November 2005   Contribution: 1    

RE: what is shadowing in .net?
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
 
Is this answer useful? Yes | No
January 19, 2006 05:25:12   #2  
samiksc Member Since: October 2005   Contribution: 233    

RE: what is shadowing in .net?

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.


 
Is this answer useful? Yes | No
April 06, 2006 03:37:41   #3  
M.Sami Member Since: April 2006   Contribution: 4    

RE: what is shadowing in .net?
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
 
Is this answer useful? Yes | No
July 01, 2006 01:56:04   #4  
Rituparno        

RE: what is shadowing in .net?
CriterionShadowingOverriding
PurposeProtecting against a subsequent base class modification introducing a member you have already defined in your derived classAchieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence
Redefined elementAny declared element typeOnly a procedure (Function or Sub) or property
Redefining elementAny declared element typeOnly a procedure or property with the identical calling sequence1
AccessibilityAny accessibilityCannot expand the accessibility of overridden element (for example, cannot override Protected with Public)
Readability and writabilityAny combinationCannot change readability or writability of overridden property
Keyword usageShadows recommended in derived class; Shadows assumed if neither Shadows nor Overrides specifiedOverridable required in base class; Overrides required in derived class
Inheritance of redefining element by classes deriving from your derived classShadowing element inherited by further derived classes; shadowed element still hidden2Overriding element inherited by further derived classes; overridden

 
Is this answer useful? Yes | No
December 11, 2006 23:05:35   #5  
hari krishna        

RE: what is shadowing in .net?

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


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape