Home > DeveloperSection > Interviews > What is the difference between shadow and override?

Posted on    February-08-2016 11:24 PM

 C# C#  ASP.Net 
 1 Answer(s)
  300  View(s)
Rate this:

Anupam Mishra

Total Post:23

Posted on    February-09-2016 12:24 AM

In general,  Overriding makes the base class method invisible. Shadowing a field only hides the field from view. we can still explicitly access the hidden shadowed field if we wish. We can't access an invisible overridden method.
When we define a class that inherits from a base class, then we are/ sometimes want to redefine one or more of the base class elements in the derived class. Shadowing and overriding are both available for this purpose.
Shadowing and overriding are both used when a derived class inherits from a base class, and both redefine one declared element with another. But there are significant differences between the two. For more details click HERE

Don't want to miss updates? Please click the below button!

Follow MindStick