dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.27k stars 5.9k forks source link

Default access #36650

Closed veroarriola closed 1 year ago

veroarriola commented 1 year ago

[Enter feedback here] What is the default access of method? In general, it would be quite useful if you added a table with default access for each component, it is a lot faster to grasp the rules.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

BillWagner commented 1 year ago

Thanks for the observation @veroarriola

We should add the defaults for all declarations:

class, struct, interface (including record types): internal all members (method, field, property, event and indexer): private

I've added this to our backlog for when we next update this article. I've also added the "help wanted" label for anyone that wants to submit a pull request before we make the updates.

svick commented 1 year ago

@BillWagner

There are some more edge cases:

  1. Nested types default to private.
  2. Members of interfaces default to public.
BartoszKlonowski commented 1 year ago

@BillWagner I will work on this!

BillWagner commented 1 year ago

Thanks @BartoszKlonowski

I've assigned it to you. I'll watch for a PR.