次の方法で共有


Attribute.GetCustomAttributes メソッド (MemberInfo, Type)

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

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

パラメータ

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

戻り値

element に適用される type 型のカスタム属性を保持している Attribute 配列。

または

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

例外

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

解説

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

必要条件

プラットフォーム: 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 オーバーロードの一覧