Complete the code to declare a record named Person.
public record [1](string Name, int Age);The keyword record is used to declare a record type. Here, Person is the record's name.
Complete the code to make Employee inherit from Person record.
public record Employee(string Name, int Age, string Position) : [1](Name, Age);The Employee record inherits from Person using the colon : followed by the base record name and parameters.
Fix the error in the code to correctly override the ToString method in the Employee record.
public record Employee(string Name, int Age) : Person(Name, Age)
{
public override string [1]() => $"Employee: {Name}, {Age}";
}toString which does not exist in C#.ToStr or Print.The method to override for string representation is ToString with capital T and S.
Fill both blanks to create a derived record Manager that inherits from Employee and adds a Department property.
public record Manager(string Name, int Age, string Position, string [1]) : Employee(Name, Age, Position) { public string [2] { get; init; } = [1]; }
The Manager record adds a Department property and passes other parameters to the Employee base record.
Fill all three blanks to override the PrintDetails method in Manager, calling base method and adding department info.
public record Manager(string Name, int Age, string Position, string Department) : Employee(Name, Age, Position)
{
public void PrintDetails()
{
base.[1]();
Console.WriteLine($"Department: [2]");
Console.WriteLine($"Position: [3]");
}
}The PrintDetails method calls the base method, then prints Department and Position properties.