HasFlag()
HasFlag()
方法可用於檢查是否設定了標誌。
Module Module1
<Flags>
Enum Material
Wood = 1
Plastic = 2
Metal = 4
Stone = 8
End Enum
Sub Main()
Dim houseMaterials As Material = Material.Wood Or Material.Stone
If houseMaterials.HasFlag(Material.Stone) Then
Console.WriteLine("the house is made of stone")
Else
Console.WriteLine("the house is not made of stone")
End If
End Sub
End Module
有關 Flags 屬性及其使用方式的更多資訊,請參閱 Microsoft 官方文件 。