创建一个枚举或枚举等价物,返回字符串(枚举返回int)在.NET中
问题描述:
我有一个URL,可以说http://www.example.com
。有时候,我需要发送HTTP和其他时间,我需要发送HTTPS。为此,我创建了一个枚举:创建一个枚举或枚举等价物,返回字符串(枚举返回int)在.NET中
Private _protocol As Protocol
Enum Protocol
HTTP
HTTPS
End Enum
Public Property protocolType() As Protocol
Get
Return _protocol
End Get
Set(ByVal value As Protocol)
_protocol = value
End Set
End Property
现在,当我从protocoltype返回值时,它将返回一个整数值作为枚举。如何获取枚举的字符串名称。
Dim targetUri As String = setting.protocolType & "://www.example.com"
感谢很多。我认为它会像2一样转换为“2”int到string(int) – 2009-12-30 05:22:34