What is the default access modifier for classes, methods, members, constructors, delegates and interfaces?
What is the default access modifier for classes, methods, members, constructors, delegates and interfaces?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The default access for everything in C# is “the most restricted access you could declare for that member”.
So for example:
is equivalent to
The one sort of exception to this is making one part of a property (usually the setter) more restricted than the declared accessibility of the property itself:
This is what the C# 3.0 specification has to say (section 3.5.1):
(Note that nested types would come under the “class members” or “struct members” parts – and therefore default to private visibility.)