This documentation is archived and is not being maintained.
CodeMemberField Class
Visual Studio 2010
Represents a declaration for a field of a type.
System::Object
System.CodeDom::CodeObject
System.CodeDom::CodeTypeMember
System.CodeDom::CodeMemberField
System.CodeDom::CodeObject
System.CodeDom::CodeTypeMember
System.CodeDom::CodeMemberField
Assembly: System (in System.dll)
The CodeMemberField type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CodeMemberField() | Initializes a new instance of the CodeMemberField class. |
![]() | CodeMemberField(CodeTypeReference, String) | Initializes a new instance of the CodeMemberField class using the specified field type and field name. |
![]() | CodeMemberField(String, String) | Initializes a new instance of the CodeMemberField class using the specified field type and field name. |
![]() | CodeMemberField(Type, String) | Initializes a new instance of the CodeMemberField class using the specified field type and field name. |
| Name | Description | |
|---|---|---|
![]() | Attributes | Gets or sets the attributes of the member. (Inherited from CodeTypeMember.) |
![]() | Comments | Gets the collection of comments for the type member. (Inherited from CodeTypeMember.) |
![]() | CustomAttributes | Gets or sets the custom attributes of the member. (Inherited from CodeTypeMember.) |
![]() | EndDirectives | Gets the end directives for the member. (Inherited from CodeTypeMember.) |
![]() | InitExpression | Gets or sets the initialization expression for the field. |
![]() | LinePragma | Gets or sets the line on which the type member statement occurs. (Inherited from CodeTypeMember.) |
![]() | Name | Gets or sets the name of the member. (Inherited from CodeTypeMember.) |
![]() | StartDirectives | Gets the start directives for the member. (Inherited from CodeTypeMember.) |
![]() | Type | Gets or sets the type of the field. |
![]() | UserData | Gets the user-definable data for the current object. (Inherited from CodeObject.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The following example demonstrates use of a CodeMemberField to declare a field of type string named testStringField.
// 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() // { // } // }
// 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);
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
