Shadowing is concept to hide functionality provided by base class member. We can also change return type of member also. In overriding we can only change definition but in shadowing we can change return type also. Below is small examplepublic class ParentClass{public int InvoiceNumber = 10;public virtual void GetInvoice() {Console.WriteLine("Invoice from base");}}public class DerivedClass:ParentClass{public new string InvoiceNumber = "10";//shadowing public new string GetInvoice() //shadowing {Console.WriteLine("Invoice from Derived");return string.Empty;}}
In shadowing, we provide a new implementation to the base class member without overriding it. We may shadow a base class member in a derived class, by using the keyword shadows. The access level, return type, and the signature (means the datatypes of the arguments passed & the order of the types) of the derived class members which are shadowed, may differ from the base class. In C#, we may achieve shadowing using the keyword new. However, when Hiding in C#, the access level, the signature, return type of the derived class must be same as the base class.http://kalitinterviewquestions.blogspot.com/
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 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.