Click here to Skip to main content
14,736,892 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please tell me...whether the keywords > public,private, protected, internal and protected internal
are called ACCESS MODIFIERS in c#? If YES,

What are the following called ? >>

sealed, abstract , readonly and const ...


regards...
Posted

sealed, abstract are modifiers too but not access modifiers

Have a look at these links.First one has more clear answer to your question

http://msdn.microsoft.com/en-us/library/6tcf2h8w.aspx[^]

http://msdn.microsoft.com/en-us/library/ms173150.aspx[^]

http://msdn.microsoft.com/en-us/library/ms173121.aspx[^]
   
Comments
   
Your links are better then others, my 5.
Please see my comments and my answer to see what were the problems with other answers.
--SA
Tiwari Avinash 10-Jul-11 1:27am
   
thanks I'm new in this S/W industry and a comment from experienced one matters me. thanks for 5 even i bookmarked ur answer.
In addition to correct answer by harish85: all correct, only in the link there are no exact explanation of access specifier application.

I suggest to use a better link: http://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx[^].

Conclusions: all key words you mentioned are, well… keywords and all are modifiers. Some subset of them are access modifiers, listed in the document referenced above. Note that "internal protected" is a special combination of the two, always used together.

Advice: do not provide more access where less access is enough. In particular, do not use public for access within the same assembly; use internal; do not use protected for access within the same assembly; use internal protected.

—SA
   
Comments
Tarun.K.S 8-Jul-11 10:36am
   
Right. My 5.
   
Thank you, Tarun.
--SA
Basically all above you have given are modifiers.
check this - (Classification of modifiers and their details
http://msdn.microsoft.com/en-us/library/6tcf2h8w(v=VS.71).aspx[^]
   
Comments
Manfred Rudolf Bihy 8-Jul-11 8:34am
   
Good link! 5+
harish85 8-Jul-11 21:24pm
   
Thanks, Manfred
[no name] 8-Jul-11 8:38am
   
Nice Link. +5.
harish85 8-Jul-11 21:24pm
   
Thanks Ramalinga
[no name] 9-Jul-11 1:37am
   
It's my pleasure.
fjdiewornncalwe 8-Jul-11 8:51am
   
Excellent Links.
harish85 8-Jul-11 21:24pm
   
Thanks Marcus
   
All correct but only one little problem: you link does not explain the usage of access specifiers. I've added a bit better link in my answer, please see. I voted 4.
--SA
harish85 8-Jul-11 11:44am
   
Yes SA, on that link , we can just click Access Modifier to reach that link.
Thanks.
1. Yes they're called access modifiers.
2. These are plainly called modifiers.

See here: http://msdn.microsoft.com/en-us/library/6tcf2h8w(v=VS.80).aspx[^]

Cheers!

—MRB
   
Comments
Tarun.K.S 8-Jul-11 8:39am
   
Exactly. 5+
   
All correct but only one little problem: you link does not explain the usage of access specifiers. I've added a bit better link in my answer, please see. I voted 4.
--SA
MSDN - Access Modifiers[^]

sealed - a class that can't be inherited

abstract - a class that MUST be inherited

readonly - a variable that cannot be modified unless done so when the variable is declared or from within the class' constructor(s)

const - a variable that must be initialized when it's defined, and cannot otherwise be changed programatically

Seriously dude, this is all essential and basic knowldeg needed to write code, and beyond that is easily found on google. If this is your version of "research", you should look for a job that adheres more closely to your work ethic.
   
Comments
[no name] 8-Jul-11 8:38am
   
Perfect. +5.
#realJSOP 8-Jul-11 8:40am
   
I think you actually forgot to vote.
[no name] 8-Jul-11 8:42am
   
Sorry.Check now JSOP
[no name] 8-Jul-11 8:43am
   
Bookmarked for future reference.
   
All correct but only one little problem: you link does not explain the usage of access specifiers. I've added a bit better link in my answer, please see. I voted 4.
--SA
#realJSOP 8-Jul-11 10:58am
   
That's because it's not FOR access specifiers. Geeze.
- Yes, public,private, protected, internal and protected internal are called Access Modifiers.
After reading SA's comments, all these are Keywords basically, also termed as Modifiers. The above list are Access Modifiers, a subset of Modifiers.

- sealed, abstract, readonly and const are called keywords. To add on, you cannot use these keywords to name your variables.
   
v3
Comments
shikhar gilhotra 8-Jul-11 8:31am
   
So what are access specifiers ???????
Tarun.K.S 8-Jul-11 8:37am
   
Same as Access Modifiers.
Tarun.K.S 8-Jul-11 10:02am
   
Can you please vote and accept the answer(s) that helped. Thank you.
   
Not 100% accurate.
The truth is here: http://msdn.microsoft.com/en-us/library/6tcf2h8w(v=VS.71).aspx.

Now, to fix your statement:
1) They all are key words.
2) They all are modifiers.
3) Sunset of modifiers is called "Access modifiers"; your list is correct.

Note: Wow: I thought only "internal protected" will compile, but "protected internal" compiled, too. I never knew that!

My 4 this time.
--SA
Tarun.K.S 8-Jul-11 10:32am
   
Hmmm you are right SA, all those are keywords. Thanks for the pointers.
I think Protected Internal is the correct way of writing.
Tarun.K.S 8-Jul-11 10:35am
   
I have modified the answer.
   
I added my answer with better link and notes on your answer, please see.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900