Type of issue
Other (describe below)
Description
Description
The declaration of the variable car2 in TestCars1 differs between the presentation of the standalone snippet test at the beginning of the article and the final code at the end.
The snippet declare car2 as a Car
Car car2 = new ConvertibleCar();
However in the full project listing at the end, the same car2 is declared as a ConvertibleCar
ConvertibleCar car2 = new ConvertibleCar();
The output is the same either way, but it's confusing. It's writent that "The type of the object is ConvertibleCar" and for the other car, the Minivan, the declared type is that of the derived class. Since TestCars2 already tests the case where all object have type Car, the final code seems more accurate.
Suggested fix
Update the standalone snippet of TestCars1 to match the full listing, i.e. use:
ConvertibleCar car2 = new ConvertibleCar();
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/knowing-when-to-use-override-and-new-keywords
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/knowing-when-to-use-override-and-new-keywords.md
Document Version Independent Id
c88cfd2b-fdee-64eb-c26c-4d808e82e8b6
Platform Id
b04bd07e-965d-f8c1-0ffe-fb4c35394fba
Article author
@BillWagner
Metadata
- ID: 4702e20f-4482-e0ce-bf61-784d436b64d5
- PlatformId: b04bd07e-965d-f8c1-0ffe-fb4c35394fba
- Service: dotnet-csharp
- Sub-service: fundamentals
Related Issues
Type of issue
Other (describe below)
Description
Description
The declaration of the variable
car2inTestCars1differs between the presentation of the standalone snippet test at the beginning of the article and the final code at the end.The snippet declare
car2as aCarHowever in the full project listing at the end, the same
car2is declared as aConvertibleCarThe output is the same either way, but it's confusing. It's writent that "The type of the object is ConvertibleCar" and for the other car, the
Minivan, the declared type is that of the derived class. SinceTestCars2already tests the case where all object have typeCar, the final code seems more accurate.Suggested fix
Update the standalone snippet of
TestCars1to match the full listing, i.e. use:Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/knowing-when-to-use-override-and-new-keywords
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/knowing-when-to-use-override-and-new-keywords.md
Document Version Independent Id
c88cfd2b-fdee-64eb-c26c-4d808e82e8b6
Platform Id
b04bd07e-965d-f8c1-0ffe-fb4c35394fba
Article author
@BillWagner
Metadata
Related Issues