In this lecture mr.Davidson mentioned multiple times that by default (if we don’t specify any access modifier) fields, methods, etc have a Private access modifier. I might be wrong, but I think c# has 4 (actually 6 if we count combinations) access modifiers: public, private, protected and internal Microsoft docs. If we don’t write the access modifier, a field for example will have an Internal modifier (not private) Default access modifier
This is not a mistake and not wrong either.
You are correct in your statement (and the link confirms it) but both you and the link refer to classes and structs (types). Rick is talking about a method and the default access modifier for class members (a method is a class member) is private.
See the C# language specification. In particular it states
1 Like
Thanks! This cleared things up for me
1 Like
No problem. Personally I prefer to add the accessibility modifiers explicitly. Then I don’t have to worry about what the default for any of them may or may not be.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.