A nested class and a struct in MyClass, and then obtains objects of the nested types : GetType « Reflection « 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 » Reflection » GetType 
19.1.3.A nested class and a struct in MyClass, and then obtains objects of the nested types
Imports System
Imports System.Reflection

Public Class MyClass1
    Public Class NestClass
        Public Shared myPublicInt As Integer = 0
    End Class

    Public Structure NestStruct
        Public myPublicInt As Integer
    End Structure
End Class

Public Class MyMainClass
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyClass1)
            Dim nestType As Type() = myType.GetNestedTypes()
            Console.WriteLine("The number of nested types is {0}.", nestType.Length)
            Dim As Type
            For Each t In nestType
                Console.WriteLine("Nested type is {0}.", t.ToString())
            Next t
        Catch As Exception
            Console.WriteLine("Error", e.Message.ToString())
        End Try
    End Sub
End Class
19.1.GetType
19.1.1.Get variable type
19.1.2.GetType Method
19.1.3.A nested class and a struct in MyClass, and then obtains objects of the nested types
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.