🌷

VB.NetでEnumの日本語名を返す拡張メソッド

2024/01/04に公開

''' <summary>
''' Enumの定義
''' </summary>
Enum SexType
    Male = 0
    Female = 1
End Enum

''' <summary>
''' 日本語名を返す拡張メソッド
''' </summary>
Module ToStringJpExtension
  Public Function ToStringJp(ByVal aEnum As SexType) As String
        Select Case aEnum
            Case SexType.Male
                Return "男"
            Case SexType.Female
                Return "女"
            Case Else
                Throw New ArgumentOutOfRangeException("SexType")
        End Select
    End Function
End Module

Discussion