-
Notifications
You must be signed in to change notification settings - Fork 6k
Clarify that abstract classes can contain implemented methods alongside abstract members #47667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ethods Co-authored-by: BillWagner <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, but I have some feedback.
docs/csharp/language-reference/keywords/snippets/abstract/Program.cs
Outdated
Show resolved
Hide resolved
docs/csharp/language-reference/keywords/snippets/abstract/Program.cs
Outdated
Show resolved
Hide resolved
docs/csharp/language-reference/keywords/snippets/abstract/Program.cs
Outdated
Show resolved
Hide resolved
docs/csharp/language-reference/keywords/snippets/abstract/abstract.csproj
Outdated
Show resolved
Hide resolved
…arget .NET 9 Co-authored-by: BillWagner <[email protected]>
docs/csharp/language-reference/keywords/snippets/abstract/Program.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now ready for final review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to fix some build errors now.
docs/csharp/language-reference/keywords/snippets/abstract/Program.cs
Outdated
Show resolved
Hide resolved
docs/csharp/language-reference/keywords/snippets/abstract/Program.cs
Outdated
Show resolved
Hide resolved
…line Co-authored-by: BillWagner <[email protected]>
Fixed the build errors by adjusting the target framework to .NET 8.0 (due to environment limitations) and ensuring proper Main method entry point. The code now builds and runs successfully. Commit: 2fd7a2a |
docs/csharp/language-reference/keywords/snippets/shared/abstract.csproj
Outdated
Show resolved
Hide resolved
Co-authored-by: BillWagner <[email protected]>
The final failure is because of a new extension feature that will be in next .NET 10 preview. |
The current documentation for the
abstract
keyword suggests that abstract classes only have "missing or incomplete implementation," which could mislead readers into thinking that ALL members in an abstract class must be abstract. This PR addresses that confusion by clearly explaining and demonstrating that abstract classes can contain both abstract and fully implemented members.Changes Made
Enhanced documentation clarity:
New comprehensive example:
Vehicle
abstract class that demonstrates mixed member types:GetInfo()
method,StartEngine()
method, constructor with functionalityMove()
method andMaxSpeed
property requiring derived class implementationCar
andBoat
) implementing the abstract members differentlyExample organization:
The enhanced documentation now makes it crystal clear that abstract classes serve as both providers of shared functionality and enforcers of required implementations, addressing the user's concern about the concept not being "obvious enough."
Fixes #28065.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Internal previews