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) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DescriptionAttribute クラス」の関連用語

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

   

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



DescriptionAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS