Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Shadowing using Shadows in Visual Basic.NE...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Shadowing using Shadows in Visual Basic.NET 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2007-07-31

    Table of Contents:
  • Shadowing using Shadows in Visual Basic.NET 2005
  • Accessing parent members when using Shadows in Visual Basic 2005
  • Using Shadows with properties in Visual Basic 2005
  • Using Shadows with methods in Visual Basic 2005
  • Using Shadows with overloaded parent methods in Visual Basic 2005
  • Using Overloads instead of Shadows with overloaded parent methods in Visual Basic 2005

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Shadowing using Shadows in Visual Basic.NET 2005 - Using Shadows with methods in Visual Basic 2005


    (Page 4 of 6 )

    In previous sections, I discussed both fields and properties using "shadows."  "Shadows" are not limited to "Fields" and "Properties;" they can also be used for "methods."  Now I'm extending  the discussion to "methods."

    Consider the following code before we proceed:

    Public Class Parent

     

      Public Sub DispMsg()

        MessageBox.Show("From Parent")

      End Sub

     

    End Class

     

    Public Class Child

      Inherits Parent

     

      Public Shadows Sub DispMsg()

        MessageBox.Show("From child")

      End Sub

     

    End Class

    In the above two classes, there exists the same method, "DispMsg," with the same signature (which may have different implementations). Thus we need "shadows."

    We can test the above classes using the following style of code:

        Dim objParent As New Parent

        Dim objChild As New Child

     

        objParent.DispMsg()

        objChild.DispMsg()

    And finally, using a parent reference, we can test as follows (which displays "From Parent"):

        Dim RefParent As Parent = objChild

        RefParent.DispMsg()

    We can even access a parent member without creating a separate reference variable as follows:

        CType(objChild, Parent).DispMsg()

    The above applies even to shadowed "fields" and "properties."

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys,Not every traditional OOP developers know about "Shadows" in Visual...
     

    VISUAL BASIC.NET ARTICLES

    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway