如何对C#代码进行排序/分组? [英] How do you sort/group your C# code?

查看:106
本文介绍了如何对C#代码进行排序/分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想知道你是如何组织(排序/订购)你的C#类代码的:


您按成员类型排序/分组:字段,方法,属性等吗?

如果是:您使用什么订购方案?


Do您可以通过可见性对成员进行分组 - 这与按类型分组有什么关系?

您在哪里插入(嵌套)类型(如枚举和委托)在类中

和命名空间?任何订单?,顶部,底部按类型分组?


我问的原因是我在ModelMaker Code中实现了排序/重新排列算法

C#类和命名空间的资源管理器。


查看ModelMaker Code Explorer的详细信息:
http://www.modelmakertools.com

感谢您的反馈,


Gerrit Beuze
ModelMaker工具

解决方案



" Gerrit Beuze" <格里特[在] MM中[点]妖[点] NL>在消息中写道

news:uO ************* @ tk2msftngp13.phx.gbl ...

大家好,
我想知道你是如何组织的(在排序/订购中)你的C#
类代码:
你是按成员类型排序/分组:字段,方法,属性等。?
如果是:您使用的订购方案是什么?

您是否按可见性对成员进行分组 - 这与按类型分组
有何关系?
你在类
和命名空间中插入(嵌套)类型如枚举和委托吗?任何订单?,顶部,底部按类型分组?


以下是我如何安排我的档案,但请不要觉得我是

暗示这是一个真实的订单。


1.公共嵌套类型

2.建筑师(公共,受保护或私人)

3.公共财产

4.公共方法

5.受保护的方法

6.私人方法

7.私人嵌套类型

8.私人会员领域


我的理由是你阅读代码就像你读了一个故事;当你进一步阅读时,你会更深入挖掘
。因此,公共嵌套类型首先出现,因为

它们通常在整个类型中使用。接下来是构造函数,所有

可访问性,因为它们给出了使用类的第一个指示

(仅受保护?静态方法?标准?等...) 。接下来剩下的

公共和受保护的东西(受保护的确是客户端的一部分

接口,所以它与公众一致)。你可以在那里停止阅读,或者在实际实施中深入挖掘
,这当然是最后的。


1和8通常在地区进行。其他的区域是共同的

功能,而不是可访问性。


希望'有意思,


Stu

我问的原因是我在ModelMaker Code Explorer中为C#类和命名空间实现了一个排序/重排算法。

检查有关ModelMaker Code Explorer的详细信息:
http://www.modelmakertools.com

感谢您的反馈,

Gerrit Beuze
ModelMaker工具



< BLOCKQUOTE> 1。嵌套类/枚举。

2.静态字段。

3.静态方法。

4.生命周期(即构造函数,最终确定)

5.公共/受保护实例字段。

6.公共/受保护实例属性。

7.公共/受保护实例方法。

8.私人实例字段。

9.私人实例属性。

10.私人实例方法。


此外,我将其中的每一个都包含在#region ... #endregion中,并在检查项目之前将它们全部折叠起来。


Chris。


" Gerrit Beuze"写道:

大家好,

我想知道你是如何组织(排序/订购)你的C#类代码:

您是按成员类型排序/分组:字段,方法,属性等?
如果是:您使用的订购方案是什么?

您是否按可见性对成员进行分组? - 这与按类型分组有什么关系?

在类
和名称空间中插入(嵌套)类型如枚举和委托的位置是什么?任何顺序?,顶部,底部按类型分组?

我问的原因是我正在ModelMaker Code Explorer中为C#类和名称空间实现排序/重排算法。

检查ModelMaker Code Explorer的详细信息:
http:// www .modelmakertools.com

感谢您的反馈,

Gerrit Beuze
ModelMaker工具






看看这篇文章

http://www.c-sharpcorner.com/Code/20...ingRegions.asp

" Chris Ballard"写道:

1.嵌套类/枚举。
2.静态字段。
3.静态方法。
4.生命周期(即构造函数) ,最终确定)
5.公共/受保护实例字段。
6.公共/受保护实例属性。
7.公共/受保护实例方法。
8.私有实例字段。< 9.私有实例属性。
10.私有实例方法。

此外,我将其中的每一个都包含在#region ... #endregion中并将它们全部折叠下来
在检查项目之前。

克里斯。

Gerrit Beuze写道:

大家好,

我想知道你是如何组织(排序/订购)你的C#类代码:

您是按成员类型排序/分组:字段,方法,属性等?
如果是:您使用的订购方案是什么?

您是否按可见性对成员进行分组? - 这与按类型分组有什么关系?

在类
和名称空间中插入(嵌套)类型如枚举和委托的位置是什么?任何顺序?,顶部,底部按类型分组?

我问的原因是我正在ModelMaker Code Explorer中为C#类和名称空间实现排序/重排算法。

检查ModelMaker Code Explorer的详细信息:
http:// www .modelmakertools.com

感谢您的反馈,

Gerrit Beuze
ModelMaker工具



Hi all,

I''m wondering if you how you organize as (in sorting / order) your C# class code:

Do you sort/ group by member type: fields, methods, properties etc.?
If yes: what ordering scheme do yo use?

Do you group members by visibility - and how does that relate to grouping by type?

Where do you insert (nested) types such as enums and delegates in classes
and namespaces? any order?, top, bottom grouped by type?

The reason I ask is that I''m implementing a sorting / rearrange algorithm
in ModelMaker Code Explorer for C# classes and namespaces.

Check for details on ModelMaker Code Explorer:
http://www.modelmakertools.com
Thanks for your feedback,

Gerrit Beuze
ModelMaker Tools

解决方案


"Gerrit Beuze" <gerrit[at]modelmaker[dot]demon[dot]nl> wrote in message
news:uO*************@tk2msftngp13.phx.gbl...

Hi all,

I''m wondering if you how you organize as (in sorting / order) your C# class code:
Do you sort/ group by member type: fields, methods, properties etc.?
If yes: what ordering scheme do yo use?

Do you group members by visibility - and how does that relate to grouping by type?
Where do you insert (nested) types such as enums and delegates in classes
and namespaces? any order?, top, bottom grouped by type?
Well the following is how I arrange my files, but please don''t feel I''m
suggesting this is the One True Order.

1. Public nested types
2. Constructors (public, protected or private)
3. Public properties
4. Public methods
5. Protected methods
6. Private methods
7. Private nested types
8. Private member fields

My rationale for this is that you read the code like you read a story; you
dig deeper as you read further. Thus public nested types go first because
they are usually used throughout the type. Constructors come next, of all
accessibility, since they give the first indication of the use of the class
(protected? static methods only? standard? etc...). Next comes the rest of
the public and protected stuff (protected really forms part of the client
interface, so it goes with public). You could stop reading there, or dig
deeper into the actual implementation, which is of course last.

1 and 8 usually go in regions. The others are regioned by common
functionality, rather than accessibility.

Hope that''s of interest,

Stu

The reason I ask is that I''m implementing a sorting / rearrange algorithm
in ModelMaker Code Explorer for C# classes and namespaces.

Check for details on ModelMaker Code Explorer:
http://www.modelmakertools.com
Thanks for your feedback,

Gerrit Beuze
ModelMaker Tools



1. Nested classes / enums.
2. Static fields.
3. Static methods.
4. Lifecycle (ie. constructor, finalize)
5. Public/Protected Instance fields.
6. Public/Protected Instance properties.
7. Public/Protected Instance methods.
8. Private Instance fields.
9. Private Instance properties.
10. Private Instance methods.

Also I enclose each of these in #region ... #endregion and collapse them all
down before checking a project in.

Chris.

"Gerrit Beuze" wrote:

Hi all,

I''m wondering if you how you organize as (in sorting / order) your C# class code:

Do you sort/ group by member type: fields, methods, properties etc.?
If yes: what ordering scheme do yo use?

Do you group members by visibility - and how does that relate to grouping by type?

Where do you insert (nested) types such as enums and delegates in classes
and namespaces? any order?, top, bottom grouped by type?

The reason I ask is that I''m implementing a sorting / rearrange algorithm
in ModelMaker Code Explorer for C# classes and namespaces.

Check for details on ModelMaker Code Explorer:
http://www.modelmakertools.com
Thanks for your feedback,

Gerrit Beuze
ModelMaker Tools





Take a look at this article

http://www.c-sharpcorner.com/Code/20...ingRegions.asp
"Chris Ballard" wrote:

1. Nested classes / enums.
2. Static fields.
3. Static methods.
4. Lifecycle (ie. constructor, finalize)
5. Public/Protected Instance fields.
6. Public/Protected Instance properties.
7. Public/Protected Instance methods.
8. Private Instance fields.
9. Private Instance properties.
10. Private Instance methods.

Also I enclose each of these in #region ... #endregion and collapse them all
down before checking a project in.

Chris.

"Gerrit Beuze" wrote:

Hi all,

I''m wondering if you how you organize as (in sorting / order) your C# class code:

Do you sort/ group by member type: fields, methods, properties etc.?
If yes: what ordering scheme do yo use?

Do you group members by visibility - and how does that relate to grouping by type?

Where do you insert (nested) types such as enums and delegates in classes
and namespaces? any order?, top, bottom grouped by type?

The reason I ask is that I''m implementing a sorting / rearrange algorithm
in ModelMaker Code Explorer for C# classes and namespaces.

Check for details on ModelMaker Code Explorer:
http://www.modelmakertools.com
Thanks for your feedback,

Gerrit Beuze
ModelMaker Tools



这篇关于如何对C#代码进行排序/分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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