Skip to content

Problem with TestCars1 example #48486

@NikolaJacques

Description

@NikolaJacques

Type of issue

Typo

Description

I am not 100% sure but I think there might be a problem in the documentation.

The 'TestCars1' example provided in the documentation has the following line of code:

ConvertibleCar car2 = new ConvertibleCar(); 

The explanation given in the article is that due to the use of the 'new' modifier in the derived class, invocation of 'ShowDetails' calls the method in the base class (Car), not the derived class (ConvertibleCar). However, this is not consistent with the code above. Instead, the code should read as:

Car 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotnet-csharp/svcfundamentals/subsvchelp wantedGood for community contributors to help [up-for-grabs]okr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions