Private Enum Hoge
Foo
Bar
End Enum
Sub Main()
Dim objectValue As Object
Dim stringValue As String
objectValue = Hoge.Bar
stringValue = objectValue.ToString()
MsgBox(stringValue) ' ← "Bar" と表示される
End Sub
ところが Option Strict Off にして Object を直接 String に代入すると
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.CompilerServices
Imports System
Namespace Application1
<StandardModule>
Friend NotInheritable Class Module1
<STAThread>
Public Shared Sub Main()
Dim stringValue As String = Conversions.ToString(Module1.Hoge.Bar)
Interaction.MsgBox(stringValue, MsgBoxStyle.OkOnly, Nothing)
End Sub
Private Enum Hoge
Foo
Bar
End Enum
End Class
End Namespace