Results 1 to 6 of 6

Thread: Overriding and Shadowing in C#

  1. #1
    Join Date
    Nov 2009
    Posts
    877

    Overriding and Shadowing in C#

    Hello, I am learning the C# programming and now I am confused about the Overriding and Shadowing in C#. I have learned it carefully. But, the concept of both of them are not able to understand. If anyone is having details about it, then please provide me help regarding it.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Overriding and Shadowing in C#

    • Shadowing : Here, super class reference able to make use of the subclass object but it is not able to get the access of the subclass member.
    • Overloading: Here, Super class reference able to make use of the subeclass object and also have the access of the sub class members.
    • There are many problems occur while using the shadowing and that is why .net had come up with the concept of the overloading.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Overriding and Shadowing in C#

    Overriding and Shadowing are used to change the working of the members of a base class. If you are making use of the Shadowing then it is concept of the VB.NET. If you are making use of the C# then you will call it as hiding. If you are making use of the shadowing then you will simply use the new implementation to the base class member than overriding it. That means make shadow of the existing base class in your derived class. For that you will make use of the shadow keyword. In C# for this new keyword is used. In case of the Overriding directly new implementation of derived class is used. If you are working on the VB.NET then you will make use of the overrides keyword and in C# you will make use of the override keyword.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Overriding and Shadowing in C#

    If you want difference between the Overriding and Shadowing in C# then you can make use of the points below:
    • Purpose of Shadowing in C# : It will protect the base class modification.
    • Purpose of Overriding in C#: It will provide you help for achieving polymorphism.
    • In Shadowing you can redefine any element type .
    • In Overriding in C# only a Function or Sub or property can be redefined.
    • Shadowing in C#Accessibility is having more accessibility.
    • Overriding in C# unable to expand the accessibility of overridden element.

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Overriding and Shadowing in C#

    The code below mentioned will provide you more help to understand the Overriding and Shadowing in C# :
    Shadowing in C#:
    Code:
    Class Older
    {
    virtual protected shadowingtest()
    {
    }
    }
    Class First : Older
    {
    protected override shadowingtest()
    {
    }
    }
    Overriding in C#:
    Code:
    Class Overridingtest
    {
    public string First( int i )
    {
    }
    public string First( string s) 
    {
    }
    public string First( int i, int j) 
    {
    }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,297

    Re: Overriding and Shadowing in C#

    I think you may need to use the books below to get more details about the Overriding and Shadowing in C#:
    • Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition (Windows.Net) by Andrew Troelsen
    • Illustrated C# 2008 (Windows.Net) by Daniel Solis
    • Professional C# 2008 by Christian Nagel, Bill Evjen, Jay Glynn, and Morgan Skinner
    • Essential LINQ (Microsoft .NET Development Series) by Charlie Calvert and Dinesh Kulkarni
    • Microsoft Visual C# 2008 Step by Step by John Sharp

Similar Threads

  1. Need help with overriding OnKeypress in windows phone 7
    By Yayati in forum Portable Devices
    Replies: 3
    Last Post: 08-11-2011, 03:25 PM
  2. Stop firefox from overriding the homepage
    By Augustine in forum Technology & Internet
    Replies: 3
    Last Post: 02-03-2011, 05:59 AM
  3. Windows 7 Scan Overriding Canon MX310
    By flosamuels in forum Operating Systems
    Replies: 1
    Last Post: 27-11-2010, 08:35 AM
  4. What is Shadowing in C# ?
    By Javiier in forum Software Development
    Replies: 3
    Last Post: 29-11-2009, 04:24 AM
  5. How to disable bios shadowing
    By PinkShell in forum Operating Systems
    Replies: 3
    Last Post: 22-08-2009, 08:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,325,889.76562 seconds with 17 queries