本文整理匯總了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