Why is the default of an access modifier "protected" in .NET?

4

Unless I'm wrong, the default when a modifier of a class is not defined, for example, is assumed to be protected :

class LoremIpsum {
    ...
}

Is there any special reason for this? which?

    
asked by anonymous 03.06.2014 / 23:34

1 answer

6

The default access modifier for a class is not protected . This is internal .

The default access modifier for a method in a class is private .

According to Jon Skeet's response, this is due to the security of the language that prevails because of the greatest restriction possible.

There are more:

  • Namespaces are public by default;
  • Interfaces are internal by default, but their members are < a href="http://msdn.microsoft.com/en-us/library/yzh058ae.aspx"> public ;
  • Types are internal by default;
  • Members of struct are private by default;
  • Enums are internal by default, with their members always < a href="http://msdn.microsoft.com/en-us/library/yzh058ae.aspx"> public ;

Language Specification: link

    
03.06.2014 / 23:37