puzzlecracker said:
/*1 not specified*/class {
/*2 not specified*/ void Foo(){}
}
Will they, like in c++, default to private?
The default accessibility is always the most private possible. So for
top-level (non-nested) types, the default access is internal. For
nested types, it's private. For methods, fields, properties, events,
constructors and constants, it's always private.
There's *one* exception to this rule, which is property access. If you
have a property like this:
public int Foo
{
get { ... };
set { ... };
}
you could make either part of it private like this:
public int Foo
{
get { ... };
private set { ... };
}
That's the only place (that I'm aware of) in C# where explicitly
specifying an access level gives you a more restricted level than the
default. (Here the default access for each part of the property is
whatever access the overall property is specified as.)