Bookcold

导航

.Net 开发习惯【转】

1、不要硬编string/ numeric,可以使用一些常量代替。 (提高可读性)

1: int Count; 2: Count = 100; 3: private static const int ZERO = 0; 4: if( Count == ZERO ) 5: { 6: // 执行一些操作 7: }

2、对于字符串比较-使用String. Empty ,而不是”"。

3、不要声明成员变量为 public 或者proteted,尽量使用private 成员变量和public/protected 属性。 (修改)

4、当我们要在循环操作字符串,使用StringBuilder,而不是字符串,示例如下。

不好的习惯:

1: String temp = String.Empty; 2: for( int i = [...]

posted on 2010-01-19 23:40  bookcold  阅读(139)  评论(0)    收藏  举报