RecordDeclaration Class
Represents a record declaration.
public class RecordDeclaration : ClassOrStructDeclarationExample
var record = new RecordDeclaration("Person");
// An accessor without statements is auto-implemented
record.Members.Add(new PropertyDeclaration("Name", typeof(string)) { Getter = new PropertyAccessorDeclaration { Statements = null } });
record.Members.Add(new PropertyDeclaration("Age", typeof(int)) { Getter = new PropertyAccessorDeclaration { Statements = null } });
Assert.Equal("""
record Person
{
string Name
{
get;
}
int Age
{
get;
}
}
""", record.ToCsharpString());- Inheritance
ClassOrStructDeclarationRecordDeclaration
Constructors
| Name | Description |
|---|---|
| RecordDeclaration() | |
| RecordDeclaration(string?) | Initializes a new instance of the RecordDeclaration class with the specified name. |
RecordDeclaration overloads
RecordDeclaration()
RecordDeclaration.cspublic RecordDeclaration()No documentation is available.
RecordDeclaration(string?)
RecordDeclaration.csInitializes a new instance of the RecordDeclaration class with the specified name.
public RecordDeclaration(string? name)Parameters
namestring?- The record name.
Properties
| Name | Description |
|---|---|
| BaseType |