VB.NET:获取实例的类名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3533774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:38:37 来源:igfitidea点击:
VB.NET: Get class name of a instance
提问by afe
Is there a way to get the instance's class name with VB.NET?
有没有办法用 VB.NET 获取实例的类名?
回答by Kelsey
回答by JaredPar
Try the following
尝试以下
Dim name = Me.GetType().Name
Or for any instance
或者对于任何实例
Dim name = theObject.GetType().Name
回答by Rajan
This could be better when you are using asp.net website class not object.
当您使用 asp.net 网站类而不是对象时,这可能会更好。
Dim ClassName as string = Me.GetType().BaseType.FullName
OR
或者
when you are using desktop app.
当您使用桌面应用程序时。
Dim ClassName as string = Me.GetType().Name

