TypeBuilder.DefineField Metoda
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Dodaje nowe pole do typu dynamicznego.
DefineField(String, Type, FieldAttributes) |
Dodaje nowe pole do typu z daną nazwą, atrybutami i typem pola. |
DefineField(String, Type, Type[], Type[], FieldAttributes) |
Dodaje nowe pole do typu z daną nazwą, atrybutami, typem pola i modyfikatorami niestandardowymi. |
- Źródło:
- TypeBuilder.cs
- Źródło:
- TypeBuilder.cs
- Źródło:
- TypeBuilder.cs
Dodaje nowe pole do typu z daną nazwą, atrybutami i typem pola.
public:
System::Reflection::Emit::FieldBuilder ^ DefineField(System::String ^ fieldName, Type ^ type, System::Reflection::FieldAttributes attributes);
public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, Type type, System.Reflection.FieldAttributes attributes);
member this.DefineField : string * Type * System.Reflection.FieldAttributes -> System.Reflection.Emit.FieldBuilder
Public Function DefineField (fieldName As String, type As Type, attributes As FieldAttributes) As FieldBuilder
Parametry
- fieldName
- String
Nazwa pola.
fieldName
nie może zawierać osadzonych wartości null.
- type
- Type
Typ pola.
- attributes
- FieldAttributes
Atrybuty pola.
Zwraca
Zdefiniowane pole.
Wyjątki
Długość fieldName
to zero.
-lub-
type
is System.Void.
-lub-
Określono całkowity rozmiar dla klasy nadrzędnej tego pola.
fieldName
to null
.
Typ został wcześniej utworzony przy użyciu polecenia CreateType().
Dotyczy
.NET 10 i inne wersje
Produkt | Wersje |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided), 2.1 |
- Źródło:
- TypeBuilder.cs
- Źródło:
- TypeBuilder.cs
- Źródło:
- TypeBuilder.cs
Dodaje nowe pole do typu z daną nazwą, atrybutami, typem pola i modyfikatorami niestandardowymi.
public:
System::Reflection::Emit::FieldBuilder ^ DefineField(System::String ^ fieldName, Type ^ type, cli::array <Type ^> ^ requiredCustomModifiers, cli::array <Type ^> ^ optionalCustomModifiers, System::Reflection::FieldAttributes attributes);
public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, Type type, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
member this.DefineField : string * Type * Type[] * Type[] * System.Reflection.FieldAttributes -> System.Reflection.Emit.FieldBuilder
Public Function DefineField (fieldName As String, type As Type, requiredCustomModifiers As Type(), optionalCustomModifiers As Type(), attributes As FieldAttributes) As FieldBuilder
Parametry
- fieldName
- String
Nazwa pola.
fieldName
nie może zawierać osadzonych wartości null.
- type
- Type
Typ pola.
- requiredCustomModifiers
- Type[]
Tablica typów reprezentujących wymagane modyfikatory niestandardowe dla pola, takie jak IsConstModifier.
- optionalCustomModifiers
- Type[]
Tablica typów reprezentujących opcjonalne modyfikatory niestandardowe dla pola, takie jak IsConstModifier.
- attributes
- FieldAttributes
Atrybuty pola.
Zwraca
Zdefiniowane pole.
Wyjątki
Długość fieldName
to zero.
-lub-
type
is System.Void.
-lub-
Określono całkowity rozmiar dla klasy nadrzędnej tego pola.
fieldName
to null
.
Typ został wcześniej utworzony przy użyciu polecenia CreateType().
Uwagi
To przeciążenie jest udostępniane projektantom zarządzanych kompilatorów.
Dotyczy
.NET 10 i inne wersje
Produkt | Wersje |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided), 2.1 |
Opinia o produkcie .NET
.NET to projekt typu open source. Wybierz link, aby przekazać opinię: