AttributeUsageAttribute(AttributeTargets) AttributeUsageAttribute(AttributeTargets) AttributeUsageAttribute(AttributeTargets) AttributeUsageAttribute(AttributeTargets) Constructor

定義

AttributeUsageAttributeAttributeTargets 値、および AllowMultiple 値の指定リストを使用して、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)

パラメーター

validOn
AttributeTargets AttributeTargets AttributeTargets AttributeTargets

有効なプログラム要素を示す、ビット単位の OR 演算を使用して組み合わせた値のセット。The set of values combined using a bitwise OR operation to indicate which program elements are valid.

DispId 属性の定義を結合するいくつかのビットごとの OR 演算の使用方法を示します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

注釈

いくつかを結合できますAttributeTargets値のビットごとの OR 演算を使用して、有効なプログラム要素の目的の組み合わせを取得します。You can combine several AttributeTargets values using a bitwise OR operation to get the desired combination of valid program elements.

既定のプロパティ値を参照してください、 ValidOnAllowMultiple、およびInheritedプロパティ。For default property values, see the ValidOn, AllowMultiple, and Inherited properties.

適用対象

こちらもご覧ください