Class Access Modifiers

G

Guest

Can anybody let me know the difference between public and private class
access modifiers? Thanks in advance
 
D

Daniel O'Connell [C# MVP]

kchalla said:
Can anybody let me know the difference between public and private class
access modifiers? Thanks in advance

Do you mean class modifiers(ie public class?) If so there is only public and
internal.
Public means that the class is available to anyone who has referenced the
assembly, while internal means the class is only accessible to the current
assembly.

private on a member means that the member is restricted to the class and its
nested classes.
 
J

Jon Skeet [C# MVP]

Daniel O'Connell said:
Do you mean class modifiers(ie public class?) If so there is only public and
internal.

Not quite - a nested class can be private, in which case it's only
visible to the enclosing class, or protected in which case it's only
visible to classes derived from the enclosing class.
 
D

Daniel O'Connell [C# MVP]

Jon Skeet said:
Not quite - a nested class can be private, in which case it's only
visible to the enclosing class, or protected in which case it's only
visible to classes derived from the enclosing class.

Ahh nested classes, my great nemisis. I constantly forget they exist(One of
my prototype compilers didn't even support them...who knows how I managed to
implement by the spec and still forget nested types). You are quite correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top