Default Access modifiers in C#?

 Posted by Poster on 3/29/2009 | Category: OOPS Interview questions | Views: 96748

An enum has default modifier as public

A class has default modifiers as Internal . It can declare members (methods etc) with following access modifiers:
protected internal

An interface has default modifier as public

A struct has default modifier as Internal and it can declare its members (methods etc) with following access modifiers:

A methods, fields, and properties has default access modifier as "Private" if no modifier is specified.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Nandakumarpb on: 8/20/2010 | Points: 10
Default modifiers of CLASS and STRUCT is not Private it is INTERNAL
Posted by: Poster on: 8/20/2010 | Points: 10
Oops sorry for the typo Nandakumarpb, I have corrected.

Your response is much appreciated.

Posted by: Imsharmi on: 2/10/2012 | Points: 10

When I cheked here '' it says ,default access modifier of class is private.

Posted by: Anup3005 on: 6/20/2012 | Points: 10
it's says that the default access modifier methods of class is private.....not class is private
Posted by: Nandakumarpb on: 6/20/2012 | Points: 10
For Imsharmi , Please read carefully Msdn mentioned (link which you posted) about the member access modifier ,means member in the class .
Check this link It says

Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified .

Login to post response