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 官方文档 。