MemberAttributes 열거형

정의

클래스 멤버의 멤버 특성 식별자를 정의합니다.

public enum class MemberAttributes
public enum MemberAttributes
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum MemberAttributes
type MemberAttributes = 
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type MemberAttributes = 
Public Enum MemberAttributes
상속
MemberAttributes
특성

필드

Abstract 1

추상 멤버입니다.

AccessMask 61440

액세스 마스크입니다.

Assembly 4096

같은 어셈블리에 있는 모든 클래스에서 액세스할 수 있는 멤버입니다.

Const 5

상수 멤버입니다.

Family 12288

해당 클래스와 파생 클래스의 패밀리에서 액세스할 수 있는 멤버입니다.

FamilyAndAssembly 8192

같은 어셈블리에 있는 해당 클래스와 파생 클래스에서 액세스할 수 있는 멤버입니다.

FamilyOrAssembly 16384

해당 클래스, 모든 어셈블리의 파생 클래스 및 같은 어셈블리의 모든 클래스에서 액세스할 수 있는 멤버입니다.

Final 2

파생 클래스에서 재정의할 수 없는 멤버입니다.

New 16

새 멤버입니다.

Overloaded 256

오버로드된 멤버입니다. Visual Basic과 같은 일부 언어에서는 오버로드된 멤버를 명시적으로 나타내야 합니다.

Override 4

기본 클래스 멤버를 재정의하는 멤버입니다.

Private 20480

프라이빗 멤버입니다.

Public 24576

공용 멤버입니다.

ScopeMask 15

범위 마스크입니다.

Static 3

정적 멤버입니다. Visual Basic에서는 Shared 키워드에 해당합니다.

VTableMask 240

VTable 마스크입니다.

예제

다음 예제 코드는 및 접근자를 사용하여 속성을 getset 정의하는 string 데 를 사용하는 CodeMemberProperty 방법을 보여 줍니다.

// Declares a property of type String named StringProperty.
CodeMemberProperty^ property1 = gcnew CodeMemberProperty;
property1->Name = "StringProperty";
property1->Type = gcnew CodeTypeReference( "System.String" );
property1->Attributes = MemberAttributes::Public;
property1->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"testStringField" ) ) );
property1->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"testStringField" ),gcnew CodePropertySetValueReferenceExpression ) );

// A C# code generator produces the following source code for the preceeding example code:
//       public virtual string StringProperty
//       {
//              get
//            {
//                return this.testStringField;
//            }
//            set
//            {
//                this.testStringField = value;
//            }
//       }
// Declares a property of type String named StringProperty.
CodeMemberProperty property1 = new CodeMemberProperty();
property1.Name = "StringProperty";
property1.Type = new CodeTypeReference("System.String");
property1.Attributes = MemberAttributes.Public;
property1.GetStatements.Add( new CodeMethodReturnStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "testStringField") ) );
property1.SetStatements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "testStringField"), new CodePropertySetValueReferenceExpression()));

// A C# code generator produces the following source code for the preceeding example code:

//       public virtual string StringProperty
//       {
//              get
//            {
//                return this.testStringField;
//            }
//            set
//            {
//                this.testStringField = value;
//            }
//       }
' Declares a property of type String named StringProperty.
Dim property1 As New CodeMemberProperty()
property1.Name = "StringProperty"
property1.Type = New CodeTypeReference("System.String")
property1.Attributes = MemberAttributes.Public
property1.GetStatements.Add(New CodeMethodReturnStatement(New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "testStringField")))
property1.SetStatements.Add(New CodeAssignStatement(New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "testStringField"), New CodePropertySetValueReferenceExpression()))

' A Visual Basic code generator produces the following source code for the preceeding example code:

'     Public Overridable Property StringProperty() As String
'         Get
'             Return Me.testStringField
'         End Get
'         Set(ByVal Value As String)
'             Me.testStringField = value
'         End Set
'     End Property

설명

열거형에 MemberAttributes 정의된 식별자를 사용하여 클래스 멤버의 scope 및 액세스 특성을 나타낼 수 있습니다.

참고

멤버 특성이 없습니다 Virtual . 멤버는 Final로 지정하지 않고 멤버 액세스를 Public(property1.Attributes = MemberAttributes.Public)으로 설정하여 가상으로 선언됩니다. 최종 플래그가 없으면 Visual BasicPublic Overridable()에서 C#(public virtual) overridable 의 멤버 virtual 가 됩니다. 멤버를 또는 overridablevirtual 선언하지 않도록 하려면 속성에서 Public 및 Final 플래그를 Attributes 모두 설정합니다. Attributes 멤버 특성 설정에 대한 자세한 내용은 속성을 참조하세요.

참고

액세스 플래그(, , PrivateAssembly또는 Family용어Public가 포함된 플래그)를 설정하는 패턴은 AccessMask 마스크를 사용하여 모든 액세스 플래그를 마스킹한 다음 원하는 액세스 플래그를 설정하는 것입니다. 예를 들어 생성자(라는 ) constructor1를 public으로 식별하는 코드 문은 입니다 constructor1.Attributes = (constructor1.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;. Attributes 속성을 액세스 플래그(예: )로 constructor1.Attributes = MemberAttributes.Public;직접 설정하면 설정될 수 있는 다른 모든 플래그가 지워집니다. 이 패턴은 ScopeMask 마스크를 사용하여 scope 플래그(추상, 최종, 정적, 재정의 또는 Const)를 설정하는 데도 사용해야 합니다.

적용 대상

추가 정보