作者:VB.NET开发
项目:Syste
Public Class GetNamesTest
Enum Colors
Red
Green
Blue
Yellow
End Enum
Enum Styles
Plaid
Striped
Tartan
Corduroy
End Enum
Public Shared Sub Main()
Console.WriteLine("The members of the Colors enum are:")
For Each s In [Enum].GetNames(GetType(Colors))
Console.WriteLine(s)
Next
Console.WriteLine()
Console.WriteLine("The members of the Styles enum are:")
For Each s In [Enum].GetNames(GetType(Styles))
Console.WriteLine(s)
Next
End Sub
End Class
作者:VB.NET开发
项目:Syste
Public Enum SignMagnitude As Integer
Negative = -1
Zero = 0
Positive = 1
End Enum
Module Example
Public Sub Main()
Dim names() As String = [Enum].GetNames(GetType(SignMagnitude))
For Each name In names
Console.WriteLine("{0,3:D} 0x{0:X} {1}",
[Enum].Parse(GetType(SignMagnitude), name),
name)
Next
End Sub
End Module