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

PropertyAttributes 列挙体

メモ : この列挙体は、互換性のために残されています。

プロパティ属性指定します

この列挙体には、メンバ値のビットごとの組み合わせ可能にする FlagsAttribute 属性含まれています。

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

<FlagsAttribute> _
<ObsoleteAttribute("PropertyAttributes has been deprecated.
  http://go.microsoft.com/fwlink/?linkid=14202")> _
Public Enumeration PropertyAttributes
Dim instance As PropertyAttributes
[FlagsAttribute] 
[ObsoleteAttribute("PropertyAttributes has been deprecated.  http://go.microsoft.com/fwlink/?linkid=14202")]
 
public enum PropertyAttributes
[FlagsAttribute] 
[ObsoleteAttribute(L"PropertyAttributes has been deprecated.  http://go.microsoft.com/fwlink/?linkid=14202")]
 
public enum class PropertyAttributes
/** @attribute FlagsAttribute() */ 
/** @attribute ObsoleteAttribute("PropertyAttributes has been deprecated.  http://go.microsoft.com/fwlink/?linkid=14202")
 */ 
public enum PropertyAttributes
FlagsAttribute 
ObsoleteAttribute("PropertyAttributes has been deprecated.  http://go.microsoft.com/fwlink/?linkid=14202")
 
public enum PropertyAttributes
メンバメンバ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

PropertyAttributes 列挙体

プロパティ関連付けることができる属性定義します。これらの属性値は corhdr.h で定義されています。

この列挙体には、メンバ値のビットごとの組み合わせ可能にする FlagsAttribute 属性含まれています。

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

<SerializableAttribute> _
<FlagsAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration PropertyAttributes
Dim instance As PropertyAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum PropertyAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum class PropertyAttributes
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum PropertyAttributes
SerializableAttribute 
FlagsAttribute 
ComVisibleAttribute(true) 
public enum PropertyAttributes
メンバメンバ
 メンバ説明
.NET Compact Framework によるサポートHasDefaultプロパティ既定値を持つことを指定します。 
.NET Compact Framework によるサポートNoneプロパティ関連付ける属性がないことを指定します。 
.NET Compact Framework によるサポートReserved2予約済み。 
.NET Compact Framework によるサポートReserved3予約済み。 
.NET Compact Framework によるサポートReserved4予約済み。 
.NET Compact Framework によるサポートReservedMaskランタイム専用予約されているフラグ指定します。 
.NET Compact Framework によるサポートRTSpecialNameメタデータ内部 API が名前のエンコーディング確認することを指定します。 
.NET Compact Framework によるサポートSpecialNameプロパティが特別であることを指定しますプロパティが特別である理由は名前で説明します。 
解説解説

PropertyAttributes取得するには、最初に Type クラス取得します。そして、その Type から PropertyInfo取得します。そして、その PropertyInfo から Attributes取得します

列挙値は、メソッド実装されている属性ビットごとの OR 演算によって組み合わせて表す数値です。

使用例使用例

3 つのプロパティビルドして、PropertyAttributes 列挙値を表示する例を次に示します読み取り専用プロパティには setter がないため、Caption = statement では変更できません。

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

' Make three properties, one read-write, one default,
' and one read-only. 
Public Class Aproperty
    ' Define a read-write property.
    Private myCaption As String
 = "A Default caption"

    Public Property Caption() As
 String
        Get
            Return myCaption
        End Get
        Set(ByVal Value As
 String)
            If myCaption <> value Then
                myCaption = value
            End If
        End Set
    End Property
End Class

Public Class Bproperty
    ' Define a default property.
    Private myCaption As String
 = "B Default caption"

    Default Public ReadOnly
 Property Item(ByVal index As
 Integer) As String
        Get
            Return "1"
        End Get
    End Property

    Public Property Caption() As
 String

        Get
            Return myCaption
        End Get
        Set(ByVal Value As
 String)
            If myCaption <> value Then
                myCaption = value
            End If
        End Set
    End Property
End Class

Public Class Cproperty
    ' Define a read-only property.
    Private myCaption As String
 = "C Default caption"

    Public ReadOnly Property
 Caption() As String
        Get
            Return myCaption
        End Get
        'No setting is allowed because this property is read-only.
    End Property
End Class


Class propertyattributesenum

    Public Shared Function
 Main() As Integer
        Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyAttributes")

        ' Determine whether a property exists, and change its value.
        Dim Mypropertya As New
 Aproperty()
        Dim Mypropertyb As New
 Bproperty()
        Dim Mypropertyc As New
 Cproperty()

        Console.Write(ControlChars.CrLf & "1. Mypropertya.Caption
 = " & _
           Mypropertya.Caption)

        Console.Write(ControlChars.CrLf & "1. Mypropertyb.Caption
 = " & _
           Mypropertyb.Caption)

        Console.Write(ControlChars.CrLf & "1. Mypropertyc.Caption
 = " & _
           Mypropertyc.Caption)

        ' Only Mypropertya can be changed because Mypropertyb is read-only.
        Mypropertya.Caption = "A- This is changed."
        Mypropertyb.Caption = "B- This is changed."
        ' Note that Mypropertyc is not changed, because it is read-only.
        Console.Write(ControlChars.CrLf & ControlChars.CrLf & _
           "2. Mypropertya.Caption = " & Mypropertya.Caption)

        Console.Write(ControlChars.CrLf & "2.Mypropertyb.Caption
 = " & _
           Mypropertyb.Caption)

        Console.Write(ControlChars.CrLf + "2. Mypropertyc.Caption
 = " & _
           Mypropertyc.Caption)

        ' Get the PropertyAttributes Enumeration of the property.
        ' Get the type.
        Dim MyTypea As Type = Type.GetType("Aproperty")
        Dim MyTypeb As Type = Type.GetType("Bproperty")
        Dim MyTypec As Type = Type.GetType("Cproperty")

        ' Get the property attributes.
        Dim Mypropertyinfoa As PropertyInfo
 = MyTypea.GetProperty("Caption")
        Dim Myattributesa As PropertyAttributes
 = Mypropertyinfoa.Attributes
        Dim Mypropertyinfob As PropertyInfo
 = MyTypeb.GetProperty("Item")
        Dim Myattributesb As PropertyAttributes
 = Mypropertyinfob.Attributes
        Dim Mypropertyinfoc As PropertyInfo
 = MyTypec.GetProperty("Caption")
        Dim Myattributesc As PropertyAttributes
 = Mypropertyinfoc.Attributes

        ' Display the property attributes value.
        Console.Write(ControlChars.CrLf & ControlChars.CrLf & "a-
 " & _
           Myattributesa.ToString())

        Console.Write(ControlChars.CrLf & "b-"
 & Myattributesb.ToString())

        Console.Write(ControlChars.CrLf & "c- "
 & Myattributesc.ToString())
        Return 0
    End Function
End Class
using System;
using System.Reflection;
 
 // Define three properties: one read-write, one default,
 // and one read only. 
public class Aproperty  
    // Define a read-write property.
{
    private string caption = "A Default
 caption";
    public string Caption
    {
        get{return caption;}
        set
        {
            if (caption != value){caption = value;}
        }
    }
}
public class Bproperty  
    // Define a default property.
{
    private string caption  = "B Default
 caption";
    public string this [int
 index]
    {
        get {return "1";}
    }
    public string Caption
    {
  
        get{return caption;}
        set
        {
            if (caption != value){caption = value;}
        }
    }
}
public class Cproperty  
    // Define a read-only property.
{
    private string caption = "C Default
 caption";
    public string Caption
    {
        get{return caption;}
        // No setting is allowed, because this is a read-only property.
    }
}
  
class propertyattributesenum
{
    public static int Main(string[]
 args)
    {
        Console.WriteLine("\nReflection.PropertyAttributes");
  
        // Determine whether a property exists, and change its value.
        Aproperty Mypropertya = new Aproperty();
        Bproperty Mypropertyb = new Bproperty();
        Cproperty Mypropertyc = new Cproperty();
  
      
        Console.Write("\n1. Mypropertya.Caption = " + Mypropertya.Caption
 );
      
        Console.Write("\n1. Mypropertyb.Caption = " + Mypropertyb.Caption
 );
      
        Console.Write("\n1. Mypropertyc.Caption = " + Mypropertyc.Caption
 );
  
        // Only Mypropertya can be changed, as Mypropertyb is read-only.
        Mypropertya.Caption = "A- This is changed.";
        Mypropertyb.Caption = "B- This is changed.";
        // Note that Mypropertyc is not changed because it is read only
  
        Console.Write("\n\n2. Mypropertya.Caption = " + Mypropertya.Caption
 );
  
        Console.Write("\n2.Mypropertyb.Caption = " + Mypropertyb.Caption
 );
 
        Console.Write("\n2. Mypropertyc.Caption = " + Mypropertyc.Caption
 );
  
        // Get the PropertyAttributes enumeration of the property.
        // Get the type.
        Type MyTypea = Type.GetType("Aproperty");
        Type MyTypeb = Type.GetType("Bproperty");
        Type MyTypec = Type.GetType("Cproperty");
  
        // Get the property attributes.
        PropertyInfo Mypropertyinfoa = MyTypea.GetProperty("Caption");
        PropertyAttributes Myattributesa = Mypropertyinfoa.Attributes;
        PropertyInfo Mypropertyinfob = MyTypeb.GetProperty("Item");
        PropertyAttributes Myattributesb = Mypropertyinfob.Attributes;
        PropertyInfo Mypropertyinfoc = MyTypec.GetProperty("Caption");
        PropertyAttributes Myattributesc = Mypropertyinfoc.Attributes;
  
        // Display the property attributes value.
      
        Console.Write("\n\na- " + Myattributesa.ToString());
  
        Console.Write("\nb-" + Myattributesb.ToString());
      
        Console.Write("\nc- " + Myattributesc.ToString());
        return 0;
    }
}
using namespace System;
using namespace System::Reflection;

// Define three properties: one read-write, one default,
// and one read only. 
// Define a read-write property.
public ref class Aproperty
{
private:
   String^ caption;

public:
   Aproperty()
      : caption( "A Default caption" )
   {}


   property String^ Caption 
   {
      String^ get()
      {
         return caption;
      }

      void set( String^ value )
      {
         if ( caption != value )
         {
            caption = value;
         }
      }

   }

};


// Define a default property.
public ref class Bproperty
{
private:
   String^ caption;

public:
   Bproperty()
      : caption( "B Default caption" )
   {}

public:
   property String^ Item
   {
      String^ get()
      {
         return "1";
      }

   }

   property String^ Caption 
   {
      String^ get()
      {
         return caption;
      }

      void set( String^ value )
      {
         if ( caption != value )
         {
            caption = value;
         }
      }

   }

};


// Define a read-only property.
public ref class Cproperty
{
private:
   String^ caption;

public:
   Cproperty()
      : caption( "C Default caption" )
   {}


   property String^ Caption 
   {
      String^ get()
      {
         return caption;
      }

   }

};

int main()
{
   Console::WriteLine( "\nReflection.PropertyAttributes" );
   
   // Determine whether a property exists, and change its value.
   Aproperty^ Mypropertya = gcnew Aproperty;
   Bproperty^ Mypropertyb = gcnew Bproperty;
   Cproperty^ Mypropertyc = gcnew Cproperty;
   Console::Write( "\n1. Mypropertya->Caption = {0}", Mypropertya->Caption
 );
   Console::Write( "\n1. Mypropertyb->Caption = {0}", Mypropertyb->Caption
 );
   Console::Write( "\n1. Mypropertyc->Caption = {0}", Mypropertyc->Caption
 );
   
   // Only Mypropertya can be changed, as Mypropertyb is read-only.
   Mypropertya->Caption = "A- This is changed.";
   Mypropertyb->Caption = "B- This is changed.";
   
   // Note that Mypropertyc is not changed because it is read only
   Console::Write( "\n\n2. Mypropertya->Caption = {0}", Mypropertya->Caption
 );
   Console::Write( "\n2.Mypropertyb->Caption = {0}", Mypropertyb->Caption
 );
   Console::Write( "\n2. Mypropertyc->Caption = {0}", Mypropertyc->Caption
 );
   
   // Get the PropertyAttributes enumeration of the property.
   // Get the type.
   Type^ MyTypea = Type::GetType( "Aproperty" );
   Type^ MyTypeb = Type::GetType( "Bproperty" );
   Type^ MyTypec = Type::GetType( "Cproperty" );
   
   // Get the property attributes.
   PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" );
   PropertyAttributes Myattributesa = Mypropertyinfoa->Attributes;
   PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "Item" );
   PropertyAttributes Myattributesb = Mypropertyinfob->Attributes;
   PropertyInfo^ Mypropertyinfoc = MyTypec->GetProperty( "Caption" );
   PropertyAttributes Myattributesc = Mypropertyinfoc->Attributes;
   
   // Display the property attributes value.
   Console::Write( "\n\na- {0}", Myattributesa );
   Console::Write( "\nb-{0}", Myattributesb );
   Console::Write( "\nc- {0}", Myattributesc );
   return 0;
}

import System.*;
import System.Reflection.*;

// Define three properties: one read-write, one default,
// and one read only. 
public class AProperty
{
    // Define a read-write property.
    private String caption = "A Default caption";

    /** @property 
     */
    public String get_Caption()
    {
        return caption ;
    } //get_Caption

    /** @property 
     */
    public void set_Caption(String value)
    {
        if (caption != value) {
            caption = value;
        }
    } //set_Caption
} //AProperty

public class BProperty
{
    // Define a default property.
    private String caption = "B Default caption";

    /** @property 
     */
    public String get_Item(int index)
    {
        return "1" ;
    } //get_Item

    /** @property 
     */
    public String get_Caption()
    {
        return caption ;
    } //get_Caption

    /** @property 
     */
    public void set_Caption (String value)
    {
        if (caption != value) {
            caption = value;
        }
    } //set_Caption
} //BProperty

public class CProperty
{
    // Define a read-only property.
    private String caption = "C Default caption";

    /** @property 
     */
    public String get_Caption()
    {
        return caption ;
        // No setting is allowed, because this is a read-only property.
    } //get_Caption
} //CProperty

class PropertyAttributesEnum
{   
    public static void main(String[]
 args)
    {
        Console.WriteLine("\nReflection.PropertyAttributes");

        // Determine whether a property exists, and change its value.
        AProperty myPropertyA =  new AProperty();
        BProperty myPropertyB =  new BProperty();
        CProperty myPropertyC =  new CProperty();

        Console.Write(("\n1. Mypropertya.Caption = " 
            + myPropertyA.get_Caption()));
        Console.Write(("\n1. Mypropertyb.Caption = " 
            + myPropertyB.get_Caption()));
        Console.Write(("\n1. Mypropertyc.Caption = " 
            + myPropertyC.get_Caption()));

        // Only myPropertyA can be changed, as myPropertyB is read-only.
        myPropertyA.set_Caption("A- This is changed.");
        myPropertyB.set_Caption("B- This is changed.");
        // Note that myPropertyC is not changed because it is read only
        Console.Write(("\n\n2. Mypropertya.Caption = " 
            + myPropertyA.get_Caption()));
        Console.Write(("\n2.Mypropertyb.Caption = " 
            + myPropertyB.get_Caption()));
        Console.Write(("\n2. Mypropertyc.Caption = " 
            + myPropertyC.get_Caption()));

        // Get the PropertyAttributes enumeration of the property.
        // Get the type.
        Type myTypeA = Type.GetType("AProperty");
        Type myTypeB = Type.GetType("BProperty");
        Type myTypeC = Type.GetType("CProperty");

        // Get the property attributes.
        PropertyInfo myPropertyInfoA = myTypeA.GetProperty("Caption");
        PropertyAttributes myAttributesA = myPropertyInfoA.get_Attributes();
        PropertyInfo myPropertyInfoB = myTypeB.GetProperty("Item");
        PropertyAttributes myAttributesB = myPropertyInfoB.get_Attributes();
        PropertyInfo myPropertyInfoC = myTypeC.GetProperty("Caption");
        PropertyAttributes myAttributesC = myPropertyInfoC.get_Attributes();

        // Display the property attributes value.
        Console.Write(("\n\nA- " + myAttributesA.ToString()));
        Console.Write(("\nB-" + myAttributesB.ToString()));
        Console.Write(("\nC- " + myAttributesC.ToString()));
    } //main
} //PropertyAttributesEnum
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「PropertyAttributes」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS