默认能见度C#类和成员(字段,方法等)? [英] Default visibility for C# classes and members (fields, methods, etc)?

查看:124
本文介绍了默认能见度C#类和成员(字段,方法等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到的C#各方面的默认可见性的参考。类类型,字段,方法,枚举等。

I'm trying to find a reference for the default visibility of various aspects of C#. Class types, fields, methods, enums, etc.

有人能与他们的默认可见性(即无prefixed改性剂)一起提供这些列表。谢谢你。

Can someone provide a list of these along with their default visibility (i.e., no prefixed modifier). Thanks.

推荐答案

所有你正在寻找的信息,可以发现的这里这里(感谢的Reed科普塞):

All of the information you are looking for can be found here and here (thanks Reed Copsey):

这是第一个链接:

类和声明直接在命名空间中(换句话说,未嵌套在其它类或结构内)结构可以是公共或内部。 内部是默认如果没有指定访问修饰符是

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.

...

对于类成员和结构成员的访问级别,包括嵌套类和结构,为私人默认

The access level for class members and struct members, including nested classes and structs, is private by default.

...

接口默认为内部访问。

...

代表行为像类和结构。默认情况下,他们有当一个命名空间中直接声明的内部访问,以及私接嵌套在

Delegates behave like classes and structs. By default, they have internal access when declared directly within a namespace, and private access when nested.

这是第二个链接:

顶级类型,这是不嵌套在其他类型的,只能内部或公众可访问性。这些类型的默认可访问性是内部

Top-level types, which are not nested in other types, can only have internal or public accessibility. The default accessibility for these types is internal.

和嵌套类型:


Members of    Default member accessibility
----------    ----------------------------
enum          public
class         private
interface     public
struct        private

这篇关于默认能见度C#类和成员(字段,方法等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆