FieldDeclaration Class

Represents a field declaration.

public class FieldDeclaration : MemberDeclaration

Example

var field = new FieldDeclaration("_count", typeof(int), Modifiers.Private, new LiteralExpression(0));

Assert.Equal("""
    private int _count = 0;

    """, field.ToCsharpString());
Inheritance
MemberDeclaration FieldDeclaration

Constructors

NameDescription
FieldDeclaration()
FieldDeclaration(string?, TypeReference?)Initializes a new instance of the FieldDeclaration class with the specified name and type.
FieldDeclaration(string?, TypeReference?, Modifiers)Initializes a new instance of the FieldDeclaration class with the specified name, type, and modifiers.
FieldDeclaration(string?, TypeReference?, Modifiers, Expression?)Initializes a new instance of the FieldDeclaration class with the specified name, type, modifiers, and initialization expression.

FieldDeclaration overloads

FieldDeclaration()

FieldDeclaration.cs
public FieldDeclaration()

No documentation is available.

FieldDeclaration(string?, TypeReference?)

FieldDeclaration.cs

Initializes a new instance of the FieldDeclaration class with the specified name and type.

public FieldDeclaration(string? name, TypeReference? type)
Parameters
name string?
The field name.
type TypeReference?
The field type.

FieldDeclaration(string?, TypeReference?, Modifiers)

FieldDeclaration.cs

Initializes a new instance of the FieldDeclaration class with the specified name, type, and modifiers.

public FieldDeclaration(string? name, TypeReference? type, Modifiers modifiers)
Parameters
name string?
The field name.
type TypeReference?
The field type.
modifiers Modifiers
The field modifiers.

FieldDeclaration(string?, TypeReference?, Modifiers, Expression?)

FieldDeclaration.cs

Initializes a new instance of the FieldDeclaration class with the specified name, type, modifiers, and initialization expression.

public FieldDeclaration(string? name, TypeReference? type, Modifiers modifiers, Expression? initExpression)
Parameters
name string?
The field name.
type TypeReference?
The field type.
modifiers Modifiers
The field modifiers.
initExpression Expression?
The field initialization expression.

Properties

NameDescription
InitExpression
Modifiers
Type

InitExpression

FieldDeclaration.cs
public Expression? InitExpression { get; set; }

Property value

Expression?

No documentation is available.

public Modifiers Modifiers { get; set; }

Property value

Modifiers

No documentation is available.

public TypeReference? Type { get; set; }

Property value

TypeReference?

No documentation is available.