摘要: 1、struct不允许显示声明其无参数构造函数,这不同于class2、struct不允许声明时,初始化其数据成员值3、struct作为参数传递时,可考虑使用ref,以优化性能:因为是值类型(但要注意其值的改变)4、struct无继承,但其本身继承自System.ValueType ----> System.Object5、struct可看作是缩小的class,适宜小数据成员时使用6、理解如下代码:... 阅读全文
posted @ 2006-06-22 07:23 FallingAutumn 阅读(2705) 评论(4) 推荐(0) 编辑
摘要: 1、const,不可改变的,声明时即必须有值。readonly则不同,声明时,可无值(默认其对应数据类型之值),且可在(也只能在这里)构造函数中初始化其值2、const隐含着static定义,readonly则必须显示声明 阅读全文
posted @ 2006-06-22 06:58 FallingAutumn 阅读(296) 评论(0) 推荐(0) 编辑
摘要: class A { static A(){} public A(){} } 1、静态构造函数和实例构造函数可共存:前者为类加载时执行,后者为new时执行2、静态构造函数无参数,且访问修饰符存在与否没意义:由.NET运行库调用3、静态构造函数使用的原因:在第一次使用类时,从外部源中初始化某些静态字段方法4、静态构造函数的执行:.NET运行库不能确保其执行时间,... 阅读全文
posted @ 2006-06-22 06:38 FallingAutumn 阅读(646) 评论(0) 推荐(0) 编辑
摘要: 代码一是正确的:代码一: public void test(int x,int y){}public void test(int x,ref int y){}public void test(int x,int y,string a){} 但代码二则有问题,compiler说已有test成员存在了代码二: public void test(int x,int y){}public int test... 阅读全文
posted @ 2006-06-22 06:15 FallingAutumn 阅读(469) 评论(2) 推荐(0) 编辑