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

A bit more detail on that (or better, why) methods that implement interface methods have to be public even with the interface method is, say, internal. #44194

Open
VesperGarment opened this issue Jan 9, 2025 · 1 comment

Comments

@VesperGarment
Copy link

VesperGarment commented Jan 9, 2025

Type of issue

Typo

Description

Is it really the case that when an interface method is, say, marked internal, an implementation for that method must be public? This seems a bit startling and worth a bit more explanation - what if the reason the method is internal in the interface is that one of its argument types is internal? Then I actually can't implement it using a normal class method - it's required to be public by this rule but it can't be public because one of its argument types isn't public.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/interfaces

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/fundamentals/types/interfaces.md

Document Version Independent Id

1f0a9a2b-6495-370d-620f-a6dabec7df3b

Article author

@BillWagner

Metadata

  • ID: d9fd340a-0f74-8602-28a1-9569296a5951
  • Service: dotnet-csharp
  • Sub-service: fundamentals

Related Issues

@BillWagner
Copy link
Member

Hi @VesperGarment

Yes, it's true that a method that implicitly implements an interface method must be public. Sharplab

The way around this is to use explicit interface implementation: Sharplab

We should include this information in the article.

@BillWagner BillWagner removed the ⌚ Not Triaged Not triaged label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants