Create a enum or enum equivalent that returns string (enum returns int) in .NET
I have a URL, lets say http://www.example.com
. Sometimes, I need to send HTTP and other times, I need to send HTTPS. For that, I created an enum:
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
Now, when I get the value back from protocoltype, it ret开发者_高级运维urns an integer value as enum. How do I get the string name of an enum.
Dim targetUri As String = setting.protocolType & "://www.example.com"
To get the string value of the Enum, use Enum.ToString()
精彩评论