AttributeUsageAttribute Constructor
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Initializes a new instance of the AttributeUsageAttribute class with the specified list of AttributeTargets, the AllowMultiple value, and the Inherited value.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub New ( _
validOn As AttributeTargets _
)
public AttributeUsageAttribute(
AttributeTargets validOn
)
Parameters
- validOn
Type: System.AttributeTargets
The set of values combined using a bitwise OR operation to indicate which program elements are valid.
Remarks
You can combine several AttributeTargets values using a bitwise OR operation to get the desired combination of valid program elements.
For default property values, see the ValidOn, AllowMultiple, and Inherited properties.
Examples
The definition of the DispId attribute illustrates the use of a bitwise OR operation to combine several AttributeTargets values.
Imports System
<AttributeUsage(AttributeTargets.Method _
Or AttributeTargets.Field _
Or AttributeTargets.Property)> _
Public Class DispIdAttribute
Inherits System.Attribute
Public Sub New(ByVal value As Integer)
' . . .
End Sub
Public ReadOnly Property Value() As Integer
Get
' . . .
Return 0
End Get
End Property
End Class
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field |
AttributeTargets.Property)]
public class DispIdAttribute : System.Attribute
{
public DispIdAttribute(int value)
{
// . . .
}
public int Value
{
get
{
// . . .
return 0;
}
}
}
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.