다음을 통해 공유


PropertyInfo.Attributes 속성

이 속성의 특성을 가져옵니다.

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public MustOverride ReadOnly Property Attributes As PropertyAttributes
‘사용 방법
Dim instance As PropertyInfo
Dim value As PropertyAttributes

value = instance.Attributes
public abstract PropertyAttributes Attributes { get; }
public:
virtual property PropertyAttributes Attributes {
    PropertyAttributes get () abstract;
}
/** @property */
public abstract PropertyAttributes get_Attributes ()
public abstract function get Attributes () : PropertyAttributes

속성 값

이 속성의 특성입니다.

설명

이 속성은 멤버에 연관된 특성을 나타냅니다. 모든 멤버에는 특정 형식의 멤버와 관련되어 정의된 일련의 특성이 있습니다. 속성 특성을 사용하면 이 속성이 기본 속성인지, SpecialName 속성 등인지 알 수 있습니다.

Attributes 속성을 가져오려면 먼저 클래스 형식을 가져옵니다. 형식에서 PropertyInfo를 가져옵니다. PropertyInfo에서 특성을 가져옵니다.

예제

다음 예제에서는 지정된 속성의 특성을 표시합니다.

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class Myproperty
    Private myCaption As String = "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 'Myproperty

Class Mypropertyinfo

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

        ' Define a property.
        Dim Myproperty As New Myproperty()
        Console.Write(ControlChars.CrLf & "Myproperty.Caption = " & _
           Myproperty.Caption)

        ' Get the type and PropertyInfo.
        Dim MyType As Type = Type.GetType("Myproperty")
        Dim Mypropertyinfo As PropertyInfo = MyType.GetProperty("Caption")

        ' Get and display the attributes property.
        Dim Myattributes As PropertyAttributes = Mypropertyinfo.Attributes

        Console.Write(ControlChars.CrLf & "PropertyAttributes - " & _
           Myattributes.ToString())

        Return 0
    End Function
End Class
using System;
using System.Reflection;
 
public class Myproperty
{
    private string caption = "Default caption";
    public string Caption
    {
        get{return caption;}
        set {if(caption!=value) {caption = value;}
        }
    }
}
  
class Mypropertyinfo
{
    public static int Main(string[] args)
    {
        Console.WriteLine("\nReflection.PropertyInfo");
  
        // Define a property.
        Myproperty Myproperty = new Myproperty();
        Console.Write("\nMyproperty.Caption = " + Myproperty.Caption);
  
        // Get the type and PropertyInfo.
        Type MyType = Type.GetType("Myproperty");
        PropertyInfo Mypropertyinfo = MyType.GetProperty("Caption");
  
        // Get and display the attributes property.
        PropertyAttributes Myattributes = Mypropertyinfo.Attributes;
      
        Console.Write("\nPropertyAttributes - " + Myattributes.ToString());
  
        return 0;
    }
}
using namespace System;
using namespace System::Reflection;
public ref class Myproperty
{
private:
   String^ caption;

public:
   Myproperty()
      : caption( "Default caption" )
   {}


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

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

   }

};

int main()
{
   Console::WriteLine( "\nReflection.PropertyInfo" );
   
   // Define a property.
   Myproperty^ myproperty = gcnew Myproperty;
   Console::Write( "\nMyproperty->Caption = {0}", myproperty->Caption );
   
   // Get the type and PropertyInfo.
   Type^ MyType = Type::GetType( "Myproperty" );
   PropertyInfo^ Mypropertyinfo = MyType->GetProperty( "Caption" );
   
   // Get and display the attributes property.
   PropertyAttributes Myattributes = Mypropertyinfo->Attributes;
   Console::Write( "\nPropertyAttributes - {0}", Myattributes );
   return 0;
}
import System.*;
import System.Reflection.*;

public class Myproperty
{
    private String caption = "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
} //Myproperty

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

        // Define a property.
        Myproperty myproperty =  new Myproperty();
        Console.Write(("\nMyproperty.Caption = " + myproperty.get_Caption()));

        // Get the type and PropertyInfo.
        Type myType = Type.GetType("Myproperty");
        PropertyInfo mypropertyinfo = myType.GetProperty("Caption");

        // Get and display the attributes property.
        PropertyAttributes myattributes = mypropertyinfo.get_Attributes();
        Console.Write(("\nPropertyAttributes - " + myattributes.ToString()));
    } //main
} //Mypropertyinfo
//Make a property, then display the PropertyInfo
import System;
import System.Reflection;

public class Myproperty
{
   private var caption : String = "Default caption";
   public function get Caption() : String {
       return caption;
   }
   public function set Caption(value:String) {
       if(caption!=value) caption = value;
   }
}
 
class Mypropertyinfo
{
   public static function Main() : void
   {
      Console.WriteLine("\nReflection.PropertyInfo");
 
      //Build a property
      var myproperty : Myproperty = new Myproperty();
      Console.Write("\nMyproperty.Caption = " + myproperty.Caption);
 
      //Get the type and PropertyInfo
      var MyType : Type = Type.GetType("Myproperty");
      var Mypropertyinfo : PropertyInfo = MyType.GetProperty("Caption");
 
      //Get and display the attributes property
      var Myattributes : PropertyAttributes = Mypropertyinfo.Attributes;
     
      Console.Write("\nPropertyAttributes - " + Myattributes.ToString());
 
   }
}
Mypropertyinfo.Main();
/*
Produces the following output

Reflection.PropertyInfo
Myproperty.Caption = Default caption
PropertyAttributes - None
*/

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

PropertyInfo 클래스
PropertyInfo 멤버
System.Reflection 네임스페이스