AttributeUsageAttribute(AttributeTargets) Constructor

Definition

Inicializuje novou instanci třídy AttributeUsageAttribute se zadaným seznamem AttributeTargets, hodnotou AllowMultiple a hodnotou Inherited.Initializes a new instance of the AttributeUsageAttribute class with the specified list of AttributeTargets, the AllowMultiple value, and the Inherited value.

public:
 AttributeUsageAttribute(AttributeTargets validOn);
public AttributeUsageAttribute (AttributeTargets validOn);
new AttributeUsageAttribute : AttributeTargets -> AttributeUsageAttribute
Public Sub New (validOn As AttributeTargets)

Parameters

validOn
AttributeTargets

Sada hodnot kombinovaná pomocí bitové operace OR k určení, které prvky programu jsou platné.The set of values combined using a bitwise OR operation to indicate which program elements are valid.

Examples

Definice atributu DispId znázorňuje použití bitové operace OR pro kombinování několika hodnot AttributeTargets.The definition of the DispId attribute illustrates the use of a bitwise OR operation to combine several AttributeTargets values.

namespace InteropServices
{
   [AttributeUsage(AttributeTargets::Method|
   AttributeTargets::Field|
   AttributeTargets::Property)
   ]
   public ref class DispIdAttribute: public Attribute
   {
   public:
      DispIdAttribute( int value )
      {
         // . . .
      }

      property int Value 
      {
         int get()
         {
            // . . .
            return 0;
         }
      }
   };
}
namespace System.Runtime.InteropServices
{
   [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field |
    AttributeTargets.Property)]
   public class DispIdAttribute: System.Attribute
   {
      public DispIdAttribute(int value) {
        // . . .
      }

      public int Value {
         get {
            // . . .
            return 0;
         }
      }
   }
}
Namespace System.Runtime.InteropServices
    
    <AttributeUsage(AttributeTargets.Method _
        Or AttributeTargets.Field _
        Or AttributeTargets.Property)> _    
    Public Class DispIdAttribute    
        Inherits System.Attribute
        
        Public Sub New(value As Integer)
            ' . . .
        End Sub
        
        Public ReadOnly Property Value() As Integer
            Get
                ' . . .
                Return 0
            End Get
        End Property
    End Class
End Namespace

Remarks

Můžete zkombinovat několik AttributeTargets hodnot pomocí bitové operace nebo a získat tak požadovanou kombinaci platných prvků programu.You can combine several AttributeTargets values using a bitwise OR operation to get the desired combination of valid program elements.

Výchozí hodnoty vlastností naleznete ve vlastnostech ValidOn, AllowMultiplea Inherited.For default property values, see the ValidOn, AllowMultiple, and Inherited properties.

Applies to

See also