FieldDeclaration Class
Represents a field declaration.
public class FieldDeclaration : MemberDeclarationExample
var field = new FieldDeclaration("_count", typeof(int), Modifiers.Private, new LiteralExpression(0));
Assert.Equal("""
private int _count = 0;
""", field.ToCsharpString());- Inheritance
MemberDeclarationFieldDeclaration
Constructors
| Name | Description |
|---|---|
| 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.cspublic FieldDeclaration()No documentation is available.
FieldDeclaration(string?, TypeReference?)
FieldDeclaration.csInitializes a new instance of the FieldDeclaration class with the specified name and type.
public FieldDeclaration(string? name, TypeReference? type)Parameters
namestring?- The field name.
typeTypeReference?- The field type.
FieldDeclaration(string?, TypeReference?, Modifiers)
FieldDeclaration.csInitializes a new instance of the FieldDeclaration class with the specified name, type, and modifiers.
public FieldDeclaration(string? name, TypeReference? type, Modifiers modifiers)Parameters
namestring?- The field name.
typeTypeReference?- The field type.
modifiersModifiers- The field modifiers.
FieldDeclaration(string?, TypeReference?, Modifiers, Expression?)
FieldDeclaration.csInitializes 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
namestring?- The field name.
typeTypeReference?- The field type.
modifiersModifiers- The field modifiers.
initExpressionExpression?- The field initialization expression.
Properties
| Name | Description |
|---|---|
| InitExpression | |
| Modifiers | |
| Type |