The ToString
method on an enum returns the string name of the enumeration. For instance:
Module Module1
Enum Size
Small
Medium
Large
End Enum
Sub Main()
Dim shirtSize As Size = Size.Medium
Dim output As String = shirtSize.ToString()
Console.WriteLine(output) ' Writes "Medium"
End Sub
End Module
If, however, the string representation of the actual integer value of the enum is desired, you can cast the enum to an Integer
and then call ToString
:
Dim shirtSize As Size = Size.Medium
Dim output As String = CInt(shirtSize).ToString()
Console.WriteLine(output) ' Writes "1"