ARTICLE

Shadowing in VB.NET

Posted by Munesh Sharma Articles | VB.NET Articles March 17, 2011
In this article i will describe Data shadowing in VB.NET
Download Files:
 
Reader Level:

Shadowing :- This is a VB.Net Concept by which you can provide a new implementation for the base class member without overriding the member. You can shadow a base class member in the derived class by using the keyword Shadows.The method signature access level and return type of the shadowed member can be completely different than the base class member.

Note:-overriding is used to redefines only the methods. but shadowing redefines the entire element.

Coding


Class
Shadow
    Shared x As Integer = 1
    Shared Sub Main()
        Dim x As Integer = 10
        '--- prints local, not class variable.
        Console.WriteLine("main: x" & x)
        '--- prints class, not local variable.
        Console.WriteLine("main sahdow x:" & Shadow.x)
    End Sub

End
Class

Output:


          Shadowing-output.gif


Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor