Difference Between Shadowing and Override in C#

Your Ad Here

Difference between Shadowing and Override in C#

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 element still overridden

 

Subscribe
Posted in Labels: kick it on DotNetKicks.com |

0 comments: