Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

default access modifier

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony - 29 Feb 2008 13:30 GMT
Hello!

I want to check with you if the following default accessmodifier is correct.

* Class outer level  = Internal
* Class that are nested = private
* field = private
* method = private
* delegate = internal

Is this correct?

Is it any more that I have forgotten?

//Tony
Jon Skeet [C# MVP] - 29 Feb 2008 13:39 GMT
> I want to check with you if the following default accessmodifier is correct.
>
[quoted text clipped - 7 lines]
>
> Is it any more that I have forgotten?

Non-class types (enums, interfaces, structs)
Properties
Events
Indexers

Basically, however, it's a simple rule: the default access is the most
private you can declare. The one exception for this is that if you set
one part of a property (i.e. either the getter or the setter) to be a
particular access level, that is always more private than it would be
otherwise.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Tony - 29 Feb 2008 14:10 GMT
Hello!
You said
> Basically, however, it's a simple rule: the default access is the most
> private you can declare. The one exception for this is that if you set
> one part of a property (i.e. either the getter or the setter) to be a
> particular access level, that is always more private than it would be
> otherwise.

but how about classes. The most private I can declare is private but the
default access is really Internal.
So have I missunderstood you in some way perhaps?

So according to your statement everything seems to have default access of
private?

//Tony

> > I want to check with you if the following default accessmodifier is correct.
> >
[quoted text clipped - 18 lines]
> particular access level, that is always more private than it would be
> otherwise.
Arne Vajhøj - 29 Feb 2008 14:21 GMT
> but how about classes. The most private I can declare is private but the
> default access is really Internal.

What would be able to use a private outer level class ?

:-)

Arne
Jon Skeet [C# MVP] - 29 Feb 2008 14:22 GMT
> Hello!
> You said
[quoted text clipped - 7 lines]
> default access is really Internal.
> So have I missunderstood you in some way perhaps?

Try declaring a non-nested class as private :)

> So according to your statement everything seems to have default access of
> private?

Nope - it's as private as you're allowed to declare it.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Alex Meleta - 29 Feb 2008 13:53 GMT
Hi Tony,

Additionally to what Jon said just a table from MS (http://msdn2.microsoft.com/en-us/library/ba0a1yw2(VS.71).aspx).
Seens a table makes more simple to catch, sometimes  :)

Regards, Alex
[TechBlog] http://devkids.blogspot.co

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.