[英]Enum to String in VB.NET [duplicate]
将“F”作为ToString()
方法的参数传递: CALLING_APP.ToString("F")
试试这个:
Private CALLING_APP As Applications= Applications.CC ' no "Const"
' CALLING_APP.ToString will return CC
Const
显然可以改变NET识别常量的方式。 作为Const,我得到了Cannot find the method on the object instance
而Intellisense正确地“看到”它。 如果由于某种原因必须使用Const
,则可以通过以下方式返回文本:
Dim strName as string = [Enum].GetName(GetType(Applications), CALLING_APP ))
它基本上是.ToString在幕后为我们所做的。 按原样输入,您的代码应该有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.