DescriptionAttributeとは? わかりやすく解説

DescriptionAttribute クラス

プロパティまたはイベントの説明を指定します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.All)> _
Public Class DescriptionAttribute
    Inherits Attribute
Dim instance As DescriptionAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public class DescriptionAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class DescriptionAttribute : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public class DescriptionAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public class DescriptionAttribute extends
 Attribute
解説解説
使用例使用例

MyImage プロパティを作成する例を次に示します。このプロパティには、DescriptionAttribute と CategoryAttribute の 2 つの属性があります。

[Description("The image associated with the control"),Category("Appearance")]
 
 public Image MyImage {
    get {
       // Insert code here.
       return image1;
    }
    set {
       // Insert code here.
    }
 }
public:
   property Image^ MyImage 
   {
      [Description("The image associated with the control"),Category("Appearance")]
      Image^ get()
      {
         // Insert code here.
         return image1;
      }

      void set( Image^ value )
      {
         // Insert code here.
      }
   }
/** @attribute Description("The image associated with the control")
    @attribute Category("Appearance")
 */
/** @property 
 */
public Image get_MyImage()
{
    // Insert code here.
    return image1;
} //get_MyImage

/** @property 
 */
public void set_MyImage(Image value)
{
    // Insert code here.
} //set_MyImage

MyImage の説明を取得する例を次に示します。最初に、オブジェクトのすべてのプロパティを保持する PropertyDescriptorCollection を取得します。次に、インデックスを付けて PropertyDescriptorCollection から MyImage を取得します。そして、このプロパティの属性を返し、その属性を属性変数に保存します。

最後に、AttributeCollection から DescriptionAttribute を取得し、取得した情報をコンソール画面に書き込むことによって、説明を出力します。

' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyImage").Attributes

' Prints the description by retrieving the DescriptionAttribute
' from the AttributeCollection. 
Dim myAttribute As DescriptionAttribute = _
    CType(attributes(GetType(DescriptionAttribute)), DescriptionAttribute)
Console.WriteLine(myAttribute.Description)
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyImage"].Attributes;
 
 /* Prints the description by retrieving the DescriptionAttribute 
  * from the AttributeCollection. */
 DescriptionAttribute myAttribute = 
    (DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
 Console.WriteLine(myAttribute.Description);
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this
 )[ "MyImage" ]->Attributes;

/* Prints the description by retrieving the DescriptionAttribute 
      * from the AttributeCollection. */
DescriptionAttribute^ myAttribute = dynamic_cast<DescriptionAttribute^>(attributes[
 DescriptionAttribute::typeid ]);
Console::WriteLine( myAttribute->Description );
// Gets the attributes for the property.
AttributeCollection attributes = TypeDescriptor.GetProperties(this).
    get_Item("MyImage").get_Attributes();

/* Prints the description by retrieving the DescriptionAttribute 
   from the AttributeCollection. 
 */
DescriptionAttribute myAttribute = (DescriptionAttribute)(attributes.
    get_Item(DescriptionAttribute.class.ToType()));

Console.WriteLine(myAttribute.get_Description());
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.DescriptionAttribute
       派生クラス
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DescriptionAttribute クラス

アセンブリ (アプリケーション)、コンポーネント、メソッド、またはインターフェイスに説明を設定します。このクラスは継承できません。

名前空間: System.EnterpriseServices
アセンブリ: System.EnterpriseServices (system.enterpriseservices.dll 内)
構文構文

<ComVisibleAttribute(False)> _
<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class
 Or AttributeTargets.Method Or AttributeTargets.Interface,
 Inherited:=True)> _
Public NotInheritable Class
 DescriptionAttribute
    Inherits Attribute
Dim instance As DescriptionAttribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface,
 Inherited=true)] 
public sealed class DescriptionAttribute :
 Attribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Method|AttributeTargets::Interface,
 Inherited=true)] 
public ref class DescriptionAttribute sealed
 : public Attribute
/** @attribute ComVisibleAttribute(false) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface,
 Inherited=true) */ 
public final class DescriptionAttribute extends
 Attribute
ComVisibleAttribute(false) 
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface,
 Inherited=true) 
public final class DescriptionAttribute extends
 Attribute
解説解説
使用例使用例

この属性の使用方法については、次のコード例を参照してください。

<Assembly: Description("A system for ensuring that the correct
 account balance is stored after a transaction.")> 
[assembly: Description("A system for ensuring that the correct
 account balance is stored after a transaction.")]
[assembly: Description("A system for ensuring that the correct
 account "
                       "balance is stored after a transaction.")];
/** @assembly Description("A system for ensuring that the
 correct account "
    + " balance is stored after a transaction.")
 */
継承階層継承階層
System.Object
   System.Attribute
    System.EnterpriseServices.DescriptionAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DescriptionAttribute コンストラクタ ()


DescriptionAttribute コンストラクタ (String)


DescriptionAttribute コンストラクタ

DescriptionAttribute クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
DescriptionAttribute () パラメータを指定せずに、DescriptionAttribute クラスの新しいインスタンスを初期化します。
DescriptionAttribute (String) 説明を指定して、DescriptionAttribute クラスの新しいインスタンスを初期化します。
参照参照

関連項目

DescriptionAttribute クラス
DescriptionAttribute メンバ
System.ComponentModel 名前空間

DescriptionAttribute コンストラクタ

DescriptionAttribute クラスの新しいインスタンスを初期化します。

名前空間: System.EnterpriseServices
アセンブリ: System.EnterpriseServices (system.enterpriseservices.dll 内)
構文構文

Dim desc As String

Dim instance As New DescriptionAttribute(desc)
public DescriptionAttribute (
    string desc
)
public:
DescriptionAttribute (
    String^ desc
)
public DescriptionAttribute (
    String desc
)
public function DescriptionAttribute (
    desc : String
)

パラメータ

desc

アセンブリ (アプリケーション)、コンポーネント、メソッド、またはインターフェイスの説明。

使用例使用例

このコンストラクタの使用方法については、次のコード例を参照してください。

<Assembly: Description("A system for ensuring that the correct
 account balance is stored after a transaction.")> 
[assembly: Description("A system for ensuring that the correct
 account balance is stored after a transaction.")]
[assembly: Description("A system for ensuring that the correct
 account "
                       "balance is stored after a transaction.")];
/** @assembly Description("A system for ensuring that the
 correct account "
    + " balance is stored after a transaction.")
 */
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DescriptionAttribute フィールド


DescriptionAttribute プロパティ


DescriptionAttribute プロパティ


DescriptionAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の DescriptionAttribute と等しいかどうかを示す値を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。  
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 これが既定の DescriptionAttribute インスタンスであるかどうかを示す値を返します。
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DescriptionAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor

DescriptionAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DescriptionAttribute クラス
System.EnterpriseServices 名前空間

DescriptionAttribute メンバ

プロパティまたはイベントの説明を指定します。

DescriptionAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DescriptionAttribute オーバーロードされます。 DescriptionAttribute クラスの新しいインスタンスを初期化します。
パブリック フィールドパブリック フィールド
  名前 説明
パブリック フィールド Default DescriptionAttribute の既定値である空の文字列 ("") を指定します。static フィールドは読み取り専用です。
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ DescriptionValue 説明として格納されている文字列を取得または設定します。
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の DescriptionAttribute と等しいかどうかを示す値を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。  
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 これが既定の DescriptionAttribute インスタンスであるかどうかを示す値を返します。
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DescriptionAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor

DescriptionAttribute メンバ

アセンブリ (アプリケーション)、コンポーネント、メソッド、またはインターフェイスに説明を設定します。このクラスは継承できません。

DescriptionAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DescriptionAttribute DescriptionAttribute クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DescriptionAttribute クラス
System.EnterpriseServices 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DescriptionAttribute」の関連用語

DescriptionAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DescriptionAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS