问题
Is there a way to get the instance's class name with VB.NET?
回答1:
Dim type As Type = yourObject.GetType()
Dim typeName As String = type.FullName
Full name will get you the fully qualified name of the Type, including the namespace of the Type.
See MSDN for more information on what is available with Type
.
回答2:
Try the following
Dim name = Me.GetType().Name
Or for any instance
Dim name = theObject.GetType().Name
回答3:
This could be better when you are using asp.net website class not object.
Dim ClassName as string = Me.GetType().BaseType.FullName
OR
when you are using desktop app.
Dim ClassName as string = Me.GetType().Name
来源:https://stackoverflow.com/questions/3533774/vb-net-get-class-name-of-a-instance