Nested Class Demo : Class Define « Class « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Class » Class DefineScreenshots 
Nested Class Demo
Nested Class Demo

Imports System

Public Class MainClass
    
    Shared Sub Main()
         Dim f1 As New Fraction(34)
         Console.WriteLine("f1: {0}", f1.ToString(  ))

         Dim fa As New Fraction.FractionArtist(  )
         fa.Draw(f1)
    End Sub
End Class


 Public Class Fraction
     Private numerator As Integer
     Private denominator As Integer

     Public Sub New_
       ByVal numerator As Integer, ByVal denominator As Integer)
         Me.numerator = numerator
         Me.denominator = denominator
     End Sub 'New

     Public Overrides Function ToString(  ) As String
         Return [String].Format("{0}/{1}", numerator, denominator)
     End Function 'ToString

     ' Nested Class
     Class FractionArtist
         Public Sub Draw(ByVal f As Fraction)
             Console.WriteLine("Drawing the numerator: {0}", f.numerator)
             Console.WriteLine_
                 "Drawing the denominator: {0}", f.denominator)
         End Sub 'Draw
     End Class 'FractionArtist

 End Class 'Fraction


           
       
Related examples in the same category
1.Your Complex Number ClassYour Complex Number Class
2.Class CompositionClass Composition
3.Define and use your own Time ClassDefine and use your own Time Class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.