次の方法で共有


Attribute.GetCustomAttribute メソッド

指定したクラス メンバに適用された指定の型のカスタム属性を取得します。

オーバーロードの一覧

指定したアセンブリに適用されている指定の型のカスタム属性、または基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Assembly, Type) As Attribute

[C#] public static Attribute GetCustomAttribute(Assembly, Type);

[C++] public: static Attribute* GetCustomAttribute(Assembly*, Type*);

[JScript] public static function GetCustomAttribute(Assembly, Type) : Attribute;

指定したクラス メンバに適用されている指定の型のカスタム属性、または基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(MemberInfo, Type) As Attribute

[C#] public static Attribute GetCustomAttribute(MemberInfo, Type);

[C++] public: static Attribute* GetCustomAttribute(MemberInfo*, Type*);

[JScript] public static function GetCustomAttribute(MemberInfo, Type) : Attribute;

指定したモジュールに適用されている指定の型のカスタム属性、または基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Module, Type) As Attribute

[C#] public static Attribute GetCustomAttribute(Module, Type);

[C++] public: static Attribute* GetCustomAttribute(Module*, Type*);

[JScript] public static function GetCustomAttribute(Module, Type) : Attribute;

指定したクラス メンバ パラメータに適用されている指定の型のカスタム属性、または基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(ParameterInfo, Type) As Attribute

[C#] public static Attribute GetCustomAttribute(ParameterInfo, Type);

[C++] public: static Attribute* GetCustomAttribute(ParameterInfo*, Type*);

[JScript] public static function GetCustomAttribute(ParameterInfo, Type) : Attribute;

指定したアセンブリに適用されている指定の型のカスタム属性、またはオプションで基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Assembly, Type, Boolean) As Attribute

[C#] public static Attribute GetCustomAttribute(Assembly, Type, bool);

[C++] public: static Attribute* GetCustomAttribute(Assembly*, Type*, bool);

[JScript] public static function GetCustomAttribute(Assembly, Type, Boolean) : Attribute;

指定したクラス メンバに適用されている指定の型のカスタム属性、またはオプションで基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(MemberInfo, Type, Boolean) As Attribute

[C#] public static Attribute GetCustomAttribute(MemberInfo, Type, bool);

[C++] public: static Attribute* GetCustomAttribute(MemberInfo*, Type*, bool);

[JScript] public static function GetCustomAttribute(MemberInfo, Type, Boolean) : Attribute;

指定したモジュールに適用されている指定の型のカスタム属性、またはオプションで基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(Module, Type, Boolean) As Attribute

[C#] public static Attribute GetCustomAttribute(Module, Type, bool);

[C++] public: static Attribute* GetCustomAttribute(Module*, Type*, bool);

[JScript] public static function GetCustomAttribute(Module, Type, Boolean) : Attribute;

指定したクラス メンバ パラメータに適用されている指定の型のカスタム属性、またはオプションで基本クラスから継承された指定の型のカスタム属性を取得します。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Shared Function GetCustomAttribute(ParameterInfo, Type, Boolean) As Attribute

[C#] public static Attribute GetCustomAttribute(ParameterInfo, Type, bool);

[C++] public: static Attribute* GetCustomAttribute(ParameterInfo*, Type*, bool);

[JScript] public static function GetCustomAttribute(ParameterInfo, Type, Boolean) : Attribute;

使用例

パラメータのカスタム属性クラスを定義し、そのカスタム属性を派生クラスおよび派生クラスの基本クラスのメソッドに適用するコード例を次に示します。この例では、 GetCustomAttribute メソッドを使用して属性を返します。

[SampleID='System.Attribute.GetCustomAttribute' SnippetID='3']

参照

Attribute クラス | Attribute メンバ | System 名前空間