What is the difference between shadow and override ?

What is the difference between shadow and override ?

Difference between shadow and override:-
  Shadowing hide the inherrited method using new keyword and CLR choose the target mthod between the parent and child  to call using the object's runtime type.Overriding hide the inherrited method using override keyword and the parent should be virtual. overrding always choose the object's compile-time type.

Differences:-
1-PorPose:-
SHADOW-Protecting against a subsequent base class modification introducing a member you have already defined in your derived class.
OVERRIDE-Achieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence

2-Redefined element:-
SHADOW:-Any declared element type.
OVERRIDE:-Only a procedure (Function or Sub) or property
3-Accessibility:-
SHADOW:-Any accessibility
OVERRIDE:-Cannot expand the accessibility of overridden element (for example cannot override Protected with Public)
4-Readability and writability
SHADOW:-Any combination
OVERRIDE:-Cannot change readability or writability of overridden property
5-Keyword usage
SHADOW:-Shadows recommended in derived class; Shadows assumed if neither Shadows nor Overrides specified.
OVERRIDE:-Overridable required in base class; Overrides required in derived class

By:kamal
Date:2013-10-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Links

C interview questions and answers for experienced and fresher