该HasFlag()方法可用于检查是否设置了标志。
Module Module1 <Flags> Enum Material Wood = 1 Plastic = 2 Metal = 4 Stone = 8 End Enum Sub Main() Dim houseMaterials As Material =Material.WoodOr 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官方文档。