ConstructorDeclaration Class
Represents a constructor declaration.
public class ConstructorDeclaration : MemberDeclarationExample
var cls = new ClassDeclaration("Person");
var ctor = cls.AddMember(new ConstructorDeclaration());
ctor.Modifiers = Modifiers.Public;
ctor.Arguments.Add(new MethodArgumentDeclaration(typeof(string), "name"));
ctor.Statements = new AssignStatement(new MemberReferenceExpression(new ThisExpression(), "_name"), new ArgumentReferenceExpression("name"));
Assert.Equal("""
class Person
{
public Person(string name)
{
this._name = name;
}
}
""", cls.ToCsharpString());- Inheritance
MemberDeclarationConstructorDeclaration
Constructors
| Name | Description |
|---|---|
| ConstructorDeclaration() |
ConstructorDeclaration()
ConstructorDeclaration.cspublic ConstructorDeclaration()No documentation is available.
Properties
| Name | Description |
|---|---|
| Arguments | |
| Initializer | |
| Modifiers | |
| ParentType | |
| Statements |
Arguments
ConstructorDeclaration.csInitializer
ConstructorDeclaration.cspublic ConstructorInitializer? Initializer { get; set; }Property value
No documentation is available.