method without access modifier

Ok this is bugging me.. I know I've read it somewhere and google isn't helping.

What is the accessibility level of a method that does not specify an access modifier?

void Foo()
{
    //code
} 

I want to say internal but I'm not 100% sure.


The default accessibility for a type is internal, but the default accesibility of that type's members depends on the type.

Generally speaking, members of a class are private by default, where as members of a struct are public by default. This varies by language; default struct access modifiers for C++ are public, where as for C#, they are private.


Assuming this is a C# method, since you have the ".net" tag.

People need to differentiate between "member" accessibility and "class" accessibility.

  • The default accessibility of class members (including methods) in C# is private. See https://msdn.microsoft.com/en-us/library/ba0a1yw2(v=vs.140).aspx
  • The default accessibility of a class itself is internal.

Yes, internal is the default for classes, but private is the default for members.