Skip to content
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

Hiding an inherited reserved method signature - No warnings if new keyword is not used #1194

Open
logeshkumars0604 opened this issue Oct 28, 2024 · 0 comments

Comments

@logeshkumars0604
Copy link

Type of issue

Other (describe below)

Description

In the example described here, it is stated that the below members of B hides the inherited reserved method signatures, and hence declared with new modifier.

public new int get_P() => 456;

public new void set_P(int value) { ... }

And according to the texts described here and here, a warning is to be issued, if the new modifier is not included in the hiding member declaration during hiding.

However, having the new keyword in the above members causes a warning, and declaring the members without the keyword doesn't cause a warning.

The question is that, if the above members hide the inherited reserved method signatures, why does having the new keyword causes a warning? Need help to understand.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/classes

Content source URL

https://github.com/dotnet/csharpstandard/blob/draft-v8/standard/classes.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant