TypeBuilder.DefineField Metoda

Definicja

Dodaje nowe pole do typu dynamicznego.

Przeciążenia

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.

DefineField(String, Type, FieldAttributes)

Ź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.

C#
public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, Type type, System.Reflection.FieldAttributes attributes);

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

DefineField(String, Type, Type[], Type[], FieldAttributes)

Ź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.

C#
public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, Type type, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
C#
public System.Reflection.Emit.FieldBuilder DefineField(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, System.Reflection.FieldAttributes attributes);

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