CodeMemberField Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Egy típusú mező deklarációját jelöli.
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
- Öröklődés
- Attribútumok
Példák
Az alábbi példa egy névvel ellátott CodeMemberFieldmező string deklarálására használhatótestStringField.
// 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 = 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
Megjegyzések
CodeMemberField egy típusú mező deklarációjának ábrázolására használható.
Konstruktorok
| Name | Description |
|---|---|
| CodeMemberField() |
Inicializálja a CodeMemberField osztály új példányát. |
| CodeMemberField(CodeTypeReference, String) |
Inicializálja az osztály új példányát a CodeMemberField megadott mezőtípus és mezőnév használatával. |
| CodeMemberField(String, String) |
Inicializálja az osztály új példányát a CodeMemberField megadott mezőtípus és mezőnév használatával. |
| CodeMemberField(Type, String) |
Inicializálja az osztály új példányát a CodeMemberField megadott mezőtípus és mezőnév használatával. |
Tulajdonságok
| Name | Description |
|---|---|
| Attributes |
Lekéri vagy beállítja a tag attribútumait. (Öröklődés forrása CodeTypeMember) |
| Comments |
Lekéri a típustag megjegyzésgyűjteményét. (Öröklődés forrása CodeTypeMember) |
| CustomAttributes |
Lekéri vagy beállítja a tag egyéni attribútumait. (Öröklődés forrása CodeTypeMember) |
| EndDirectives |
Lekéri a tagra vonatkozó záró irányelveket. (Öröklődés forrása CodeTypeMember) |
| InitExpression |
Lekéri vagy beállítja a mező inicializálási kifejezését. |
| LinePragma |
Lekéri vagy beállítja azt a sort, amelyen a típustag-utasítás történik. (Öröklődés forrása CodeTypeMember) |
| Name |
Lekéri vagy beállítja a tag nevét. (Öröklődés forrása CodeTypeMember) |
| StartDirectives |
Lekéri a kezdő irányelveket a tag számára. (Öröklődés forrása CodeTypeMember) |
| Type |
Lekéri vagy beállítja a mező típusát. |
| UserData |
Lekéri az aktuális objektum felhasználó által definiálható adatait. (Öröklődés forrása CodeObject) |
Metódusok
| Name | Description |
|---|---|
| Equals(Object) |
Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal. (Öröklődés forrása Object) |
| GetHashCode() |
Ez az alapértelmezett kivonatoló függvény. (Öröklődés forrása Object) |
| GetType() |
Lekéri az Type aktuális példányt. (Öröklődés forrása Object) |
| MemberwiseClone() |
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| ToString() |
Az aktuális objektumot jelképező sztringet ad vissza. (Öröklődés forrása Object) |