C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
3
Reply
What is Shadowing in C#?
Santosh Kumar
14y
35.2k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
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;}}
Dhanik Sahni
11y
0
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/
kalit sikka
14y
0
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.
Santosh Kumar
14y
0
What is the "this" keyword in C# ?
What is the Application domain (C#)?
Message