Vehicle with properties Make and Year.Car that inherits from Vehicle and adds a property Model.Car with specific values for Make, Year, and Model.Car instance.Vehicle with properties Make and Year.Car that inherits from Vehicle and adds a property Model.Car with specific values for Make, Year, and Model.Car instance.Vehicle with two properties: string Make and int Year. Use positional parameters in the record definition.Use the syntax public record Vehicle(string Make, int Year); to create a record with two properties.
Car that inherits from Vehicle. Add a new property string Model using positional parameters. Make sure Car calls the base record constructor for Make and Year.Use public record Car(string Make, int Year, string Model) : Vehicle(Make, Year); to inherit and add a property.
myCar and assign it a new Car object with Make as "Toyota", Year as 2022, and Model as "Corolla".Use Car myCar = new Car("Toyota", 2022, "Corolla"); to create the object.
Console.WriteLine statement to print the myCar object. This will show all property values.Use Console.WriteLine(myCar); inside a Main method to print the record.
What does record inheritance in C# allow you to do?
Which of the following is the correct syntax to inherit a record Person in C#?
public record Person(string Name, int Age);
: to inherit and passes base parameters in parentheses after the base name.What will be the output of this code?
public record Person(string Name, int Age);
public record Employee(string Name, int Age, string Position) : Person(Name, Age);
var emp = new Employee("Alice", 30, "Developer");
Console.WriteLine(emp.Name + ", " + emp.Age + ", " + emp.Position);Identify the error in this record inheritance code:
public record Person(string Name, int Age);
public record Employee(string Name, int Age, string Position) : Person;
var emp = new Employee("Bob", 25, "Tester");: Person(Name, Age). Omitting them causes a compilation error.You have a base record Vehicle(string Make, string Model). You want to create a derived record Car that adds int Doors and overrides the ToString() method to show all info. Which is the correct way to do this?
: Vehicle(Make, Model).Pass the test and this pattern moves unknown