A nested class and a struct in MyClass, and then obtains objects of the nested types : GetType « Reflection « VB.Net Tutorial






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 t As Type
            For Each t In nestType
                Console.WriteLine("Nested type is {0}.", t.ToString())
            Next t
        Catch e 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