你怎样在C#3.0的源$ C ​​$ C元素呢?

问题描述:

请问下面看看好不好?

编辑:选项是一般性质的,可能没有穷尽在C#中的元素方面

Options are general in nature, may not be exhaustive in terms of C# elements.

单一来源文件可以包含以下内容:

Single Source file can contain following:

文件就可以派上双 - 可编辑+生成 单个文件只能有一个名称空间。

Files can come in pair - Editable + Generated Single file can have only one name-space.

  • 在每个文件中的一个部分或完整的类
  • 在每个文件的零个或多个枚举
  • 在每个文件的零个或多个结构
  • 在每个文件的零个或多个委托类型
  • 在每个文件中的一个或多个接口
  • 在每个文件一个静态类

之后,将有在给定顺序的部分。

枚举 - 场 - 属性 - 活动 - 代表 - 方法

在每一节中,元素将被访问责令即公共方法将出庭私有方法。内蒙古类型可以有任意两个部分之间他们自己的部分。任选地,相关的字段和属性可以组合在一起。

There will be following sections in given Order.

Enums - Fields - Properties - Events - Delegates - Methods

Within each section, elements will be ordered by accessibility i.e. public methods will appear before private methods. Inner types can have their own section between any two sections. Optionally, related fields and properties can be grouped together.

集团密切相关的元素不看访问级别。使用地区没有失败。

Group closely related elements without looking at accessibility level. Use regions without fail.

也就无所谓了。让VS帮助你。

Just do not care. Let VS help you.

你们有什么想,怎么办?

What do you guys think and do?

我只有每个文件的单个元素。如果你需要组东西放在一起整理起来,那就是命名空间是。

I only have a single element per file. If you need to group things together to tidy them up, then that is what namespaces are for.

我也倾向于粘字段和属性在类的顶部,随后由该构造,然后方法。我经常保持私有方法旁边的公共那些使用它们。

I also tend to stick fields and properties at the top of classes, followed by the constructors, then methods. I usually keep private methods next to the public ones that use them.

编辑:在任何情况下,你应该使用的区域!永远。在所有。如果youre类是这么大,你需要折叠起来您一定差远了问题,担心巨大的部分。

And under no circumstances should you use regions! ever. at all. If youre class is so big you need to collapse huge portions of it youve got far worse problems to worry about.