default access for class members in C#?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

In C++, default access is private. In Java, default access is package. In
C++, default access is ___________ ??
 
Hi Bob,

I assume you meant - "In C# default access is ___________ ??"
In C#, the default access is private if no access modifiers are specified.

Regards,
Aravind C
 
Bob said:
In C++, default access is private. In Java, default access is package. In
C++, default access is ___________ ??

The default _accessibility_ of type members is private. Note though that the
default _visibility_ of non-nested types is internal.
Cheers
Jon Jagger
 
Jon Jagger said:
The default _accessibility_ of type members is private. Note though that the
default _visibility_ of non-nested types is internal.

The easy way to remember it (IMO) is that C# assumes you want the most
restricted access available for anything. That's great, because it
means you can cheerfully go with the defaults and get a visual reminder
(in the form of an accessibility keyword) when you *don't* want the
most private access. Making things "more private" is much less likely
to be a mistake than making things "less private", as it will be picked
up at compile time. (The exception to this rule is when reflection is
used, of course.)
 
Back
Top