PropertyDeclaration Class

Represents a property declaration.

public class PropertyDeclaration : MemberDeclaration

Example

var prop = new PropertyDeclaration("Name", typeof(string));
prop.Modifiers = Modifiers.Public;
prop.Getter = new ReturnStatement(new MemberReferenceExpression(new ThisExpression(), "_name"));
prop.Setter = new AssignStatement(new MemberReferenceExpression(new ThisExpression(), "_name"), new ValueArgumentExpression());

Assert.Equal("""
    public string Name
    {
        get
        {
            return this._name;
        }
        set
        {
            this._name = value;
        }
    }

    """, prop.ToCsharpString());
Inheritance
MemberDeclaration PropertyDeclaration

Constructors

NameDescription
PropertyDeclaration()
PropertyDeclaration(string?, TypeReference?)Initializes a new instance of the PropertyDeclaration class with the specified name and type.

PropertyDeclaration overloads

PropertyDeclaration()

PropertyDeclaration.cs
public PropertyDeclaration()

No documentation is available.

PropertyDeclaration(string?, TypeReference?)

PropertyDeclaration.cs

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

public PropertyDeclaration(string? name, TypeReference? type)
Parameters
name string?
The property name.
type TypeReference?
The property type.

Properties

NameDescription
Getter
Modifiers
PrivateImplementationType
Setter
Type
public PropertyAccessorDeclaration? Getter { get; set; }

No documentation is available.

public Modifiers Modifiers { get; set; }

Property value

Modifiers

No documentation is available.

PrivateImplementationType

PropertyDeclaration.cs
public TypeReference? PrivateImplementationType { get; set; }

Property value

TypeReference?

No documentation is available.

public PropertyAccessorDeclaration? Setter { get; set; }

No documentation is available.

public TypeReference? Type { get; set; }

Property value

TypeReference?

No documentation is available.