Use MyClass : MyClass « Class Module « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Class Module » MyClass 
6.20.1.Use MyClass
Class Base
    Public Function Message() As String
        Message = "Hello, World from Base Class"
    End Function

    Public Overridable Function Message2() As String
        Message2 = "Base Class Message 2"
    End Function

    Public Sub ShowMessages()
        Console.WriteLine(MyClass.Message())
        Console.WriteLine(MyClass.Message2())
    End Sub

End Class

Class Derived
    Inherits Base

    Public Shadows Function Message() As String
        Message = "Hi, from Derived Class"
    End Function

    Public Overrides Function Message2() As String
        Message2 = "Derived Class Message 2"
    End Function

End Class

Module Module1

    Sub Main()

        Dim BaseObj As New Base()
        Dim DerivedObj As New Derived()

        Console.WriteLine("Base object Message: " & BaseObj.Message())
        Console.WriteLine("Derived object Message: " & DerivedObj.Message())

        Dim MixedObj As Base = New Derived()
        Console.WriteLine("Mixed message: " & MixedObj.Message())

        Console.WriteLine("Base object Message2: " & BaseObj.Message2())
        Console.WriteLine("Derived object Message2: " & DerivedObj.Message2())
        Console.WriteLine("Mixed message2: " & MixedObj.Message2())

        Console.WriteLine()
        Console.WriteLine("Mixed using MyClass")
        MixedObj.ShowMessages()
    End Sub

End Module
Base object Message: Hello, World from Base Class
Derived object Message: Hi, from Derived Class
Mixed message: Hello, World from Base Class
Base object Message2: Base Class Message 2
Derived object Message2: Derived Class Message 2
Mixed message2: Derived Class Message 2

Mixed using MyClass
Hello, World from Base Class
Base Class Message 2
6.20.MyClass
6.20.1.Use MyClass
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.