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.
Login to rate this answer.
Sameeksha
Answered On : Dec 5th, 2005
I find this table from MSDN to be useful to explain differences between shadowing and overriding: The main constraint on overriding is that it needs permission from the base class with the 'overridable' keyword. Shadowing does not require permission of base class.
| 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 element still overridden |

1 User has rated as useful.
Login to rate this answer.
Hector
Answered On : Nov 14th, 2006
This is wrong: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.The right this is the opossite: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 compile-time type..Overriding hide the inherrited method using override keyword and the parent should be virtual. overrding always choose the object's run-time type.public class Base{ public virtual void SomeMethod() { }}public class Derived : Base{ public override void SomeMethod() { }}// override works with the object run-time type Base b = new Derived();b.SomeMethod();It will execute Derived.SomeMethod because b is type Derived on runtime type.try MessageBox.Show(b.GetType().ToString()) to proof it.Now instead:public class Base{ public virtual void SomeOtherMethod() { }}public class Derived : Base{ public new void SomeOtherMethod() { }}...Base b = new Derived();Derived d = new Derived();b.SomeOtherMethod();d.SomeOtherMethod();Will first call Base.SomeOtherMethod, because b is Base type at compile time and Derived type at runtimethen Derived.SomeOtherMethod because d is Base type at compile time and Derived type at runtime

1 User has rated as useful.
Login to rate this answer.
In shadowing the Access Level , Return Type and Signature of the method can change in the drived class where as in overriding access level, return type and signature of the method has to be same.
Login to rate this answer.