本文整理汇总了VB.NET中System.AttributeTargets枚举的典型用法代码示例。如果您正苦于以下问题:VB.NET AttributeTargets枚举的具体用法?VB.NET AttributeTargets怎么用?VB.NET AttributeTargets使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了AttributeTargets枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DemoModule
Module DemoModule
' This attribute is only valid on a class.
<AttributeUsage(AttributeTargets.Class)> _
Public Class ClassTargetAttribute
Inherits Attribute
End Class
' This attribute is only valid on a method.
<AttributeUsage(AttributeTargets.Method)> _
Public Class MethodTargetAttribute
Inherits Attribute
End Class
' This attribute is only valid on a constructor.
<AttributeUsage(AttributeTargets.Constructor)> _
Public Class ConstructorTargetAttribute
Inherits Attribute
End Class
' This attribute is only valid on a field.
<AttributeUsage(AttributeTargets.Field)> _
Public Class FieldTargetAttribute
Inherits Attribute
End Class
' This attribute is valid on a class or a method.
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Method)> _
Public Class ClassMethodTargetAttribute
Inherits Attribute
End Class
' This attribute is valid on any target.
<AttributeUsage(AttributeTargets.All)> _
Public Class AllTargetsAttribute
Inherits Attribute
End Class
<ClassTarget, _
ClassMethodTarget, _
AllTargets> _
Public Class TestClassAttribute
<ConstructorTarget, _
AllTargets> _
Public Sub New
End Sub
<MethodTarget, _
ClassMethodTarget, _
AllTargets> _
Public Sub Method1()
End Sub
<FieldTarget, _
AllTargets> _
Public myInt as Integer
End Class
Sub Main()
End Sub
End Module