Share via


CodeMemberField 클래스

정의

형식의 필드에 대한 선언을 나타냅니다.

public ref class CodeMemberField : System::CodeDom::CodeTypeMember
public class CodeMemberField : System.CodeDom.CodeTypeMember
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeMemberField : System.CodeDom.CodeTypeMember
type CodeMemberField = class
    inherit CodeTypeMember
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeMemberField = class
    inherit CodeTypeMember
Public Class CodeMemberField
Inherits CodeTypeMember
상속
CodeMemberField
특성

예제

다음 예제에서는 를 사용하여 CodeMemberField 라는 testStringField형식 string 의 필드를 선언하는 방법을 보여 줍니다.

// Declares a type to contain a field and a constructor method.
CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "FieldTest" );

// Declares a field of type String named testStringField.
CodeMemberField^ field1 = gcnew CodeMemberField( "System.String","TestStringField" );
type1->Members->Add( field1 );

// Declares an empty type constructor.
CodeConstructor^ constructor1 = gcnew CodeConstructor;
constructor1->Attributes = MemberAttributes::Public;
type1->Members->Add( constructor1 );

// A C# code generator produces the following source code for the preceeding example code:
//    public class FieldTest 
//    {
//      private string testStringField;
//        
//        public FieldTest() 
//        {
//        }                            
//    }
// Declares a type to contain a field and a constructor method.
CodeTypeDeclaration type1 = new CodeTypeDeclaration("FieldTest");

// Declares a field of type String named testStringField.
CodeMemberField field1 = new CodeMemberField("System.String", "TestStringField");
type1.Members.Add( field1 );

// Declares an empty type constructor.
CodeConstructor constructor1 = new CodeConstructor();
constructor1.Attributes = MemberAttributes.Public;
type1.Members.Add( constructor1 );

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

//    public class FieldTest
//    {
//      private string testStringField;
//
//        public FieldTest()
//        {
//        }
//    }
' Declares a type to contain a field and a constructor method.
Dim type1 As New CodeTypeDeclaration("FieldTest")

' Declares a field of type String named testStringField.
Dim field1 As New CodeMemberField("System.String", "testStringField")
type1.Members.Add(field1)

' Declares an empty type constructor.
Dim constructor1 As New CodeConstructor()
constructor1.Attributes = MemberAttributes.Public
type1.Members.Add(constructor1)

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

' Public Class FieldTest
'
'     Private TestStringField As String
'
'     Public Sub New()
'         MyBase.New()
'     End Sub
'
' End Class
// This example demonstrates declaring a public constant type member field.

// When declaring a public constant type member field, you must set a particular
// access and scope mask to the member attributes of the field in order for the
// code generator to properly generate the field as a constant field.

// Declares an integer field using a CodeMemberField
CodeMemberField^ constPublicField = gcnew CodeMemberField( int::typeid,"testConstPublicField" );

// Resets the access and scope mask bit flags of the member attributes of the field
// before setting the member attributes of the field to public and constant.
constPublicField->Attributes = (MemberAttributes)((constPublicField->Attributes &  ~MemberAttributes::AccessMask &  ~MemberAttributes::ScopeMask) | MemberAttributes::Public | MemberAttributes::Const);
// This example demonstrates declaring a public constant type member field.

// When declaring a public constant type member field, you must set a particular
// access and scope mask to the member attributes of the field in order for the
// code generator to properly generate the field as a constant field.

// Declares an integer field using a CodeMemberField
CodeMemberField constPublicField = new CodeMemberField(typeof(int), "testConstPublicField");

// Resets the access and scope mask bit flags of the member attributes of the field
// before setting the member attributes of the field to public and constant.
constPublicField.Attributes = (constPublicField.Attributes & ~MemberAttributes.AccessMask & ~MemberAttributes.ScopeMask) | MemberAttributes.Public | MemberAttributes.Const;
' This example demonstrates declaring a public constant type member field.
' When declaring a public constant type member field, you must set a particular
' access and scope mask to the member attributes of the field in order for the
' code generator to properly generate the field as a constant field.
' Declares an integer field using a CodeMemberField
Dim constPublicField As New CodeMemberField(GetType(Integer), "testConstPublicField")

' Resets the access and scope mask bit flags of the member attributes of the field
' before setting the member attributes of the field to public and constant.
constPublicField.Attributes = constPublicField.Attributes And Not MemberAttributes.AccessMask And Not MemberAttributes.ScopeMask Or MemberAttributes.Public Or MemberAttributes.Const

설명

CodeMemberField 는 형식의 필드에 대한 선언을 나타내는 데 사용할 수 있습니다.

생성자

CodeMemberField()

CodeMemberField 클래스의 새 인스턴스를 초기화합니다.

CodeMemberField(CodeTypeReference, String)

지정된 필드 형식과 필드 이름을 사용하여 CodeMemberField 클래스의 새 인스턴스를 초기화합니다.

CodeMemberField(String, String)

지정된 필드 형식과 필드 이름을 사용하여 CodeMemberField 클래스의 새 인스턴스를 초기화합니다.

CodeMemberField(Type, String)

지정된 필드 형식과 필드 이름을 사용하여 CodeMemberField 클래스의 새 인스턴스를 초기화합니다.

속성

Attributes

멤버의 특성을 가져오거나 설정합니다.

(다음에서 상속됨 CodeTypeMember)
Comments

형식 멤버의 주석 컬렉션을 가져옵니다.

(다음에서 상속됨 CodeTypeMember)
CustomAttributes

멤버의 사용자 지정 특성을 가져오거나 설정합니다.

(다음에서 상속됨 CodeTypeMember)
EndDirectives

멤버의 종료 지시문을 가져옵니다.

(다음에서 상속됨 CodeTypeMember)
InitExpression

필드의 초기화 식을 가져오거나 설정합니다.

LinePragma

형식 멤버 문이 있는 줄을 가져오거나 설정합니다.

(다음에서 상속됨 CodeTypeMember)
Name

멤버의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 CodeTypeMember)
StartDirectives

멤버의 시작 지시문을 가져옵니다.

(다음에서 상속됨 CodeTypeMember)
Type

필드의 데이터 형식을 가져오거나 설정합니다.

UserData

현재 개체에 대해 사용자 정의 가능한 데이터를 가져옵니다.

(다음에서 상속됨 CodeObject)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상