次の方法で共有


Attribute.GetCustomAttributes メソッド (MemberInfo)

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

Overloads Public Shared Function GetCustomAttributes( _
   ByVal element As MemberInfo _) As Attribute()
[C#]
public static Attribute[] GetCustomAttributes(MemberInfoelement);
[C++]
public: static Attribute* GetCustomAttributes(MemberInfo* element) [];
[JScript]
public static function GetCustomAttributes(
   element : MemberInfo) : Attribute[];

パラメータ

  • element
    クラスのコンストラクタ メンバ、イベント メンバ、フィールド メンバ、メソッド メンバ、またはプロパティ メンバを記述する MemberInfo クラスから派生したオブジェクト。

戻り値

element に適用されるカスタム属性を格納している Attribute 配列。

または

そのようなカスタム属性が存在しない場合は空の配列。

例外

例外の種類 条件
ArgumentNullException element が null 参照 (Visual Basic では Nothing) です。
NotSupportedException element がコンストラクタ、メソッド、プロパティ、イベント、型、またはフィールドではありません。

解説

戻り値には、 element の祖先のカスタム属性が含まれます。

パラメータとして MemberInfo を受け取る GetCustomAttribute の使用方法については、次のコード例を参照してください。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

Attribute クラス | Attribute メンバ | System 名前空間 | Attribute.GetCustomAttributes オーバーロードの一覧