.net应用程序的默认访问说明是什么

.net应用程序的默认访问说明是什么

问题描述:

我想要什么是整个整个.net应用程序的默认访问说明符.

i want what is default access specifier for hole entire .net application

应用程序中没有用于所有对象的说明符.
对于紧接在名称空间(即顶层)中的类和结构,默认访问说明符为internal
对于类中的类和结构,属性,字段,枚举和方法,它为private

但是,始终始终声明访问说明符是一个非常非常好的主意-这样您就不会犯错,并且它迫使您考虑哪种访问方式适合于此.

请参见 MDSN [
There is no one specifier for all objects within an application.
For classes and structs immediately within a namespace (i.e. at the top level) the default access specifier is internal
For classes and structs, properties, fields, enums and methods within a class it is private

However, it is a very, very good idea to absolutely state the access specifier at all times - that way you cannot make a mistake, and it forces you to think about what kind of access is appropriate for it.

See MDSN[^]


http://www.dotnetfunda.com/interview/exam425-default-access-modifiers -in-csharp.aspx [ ^ ]