摘要: 1. 接口和抽象类有很多共同点, 都是声明变量, 不能被实例化. 并且其中的方法都不提供实现代码.2. 接口的任何派生类型(类或接口)都必须继承该接口定义的所有方法, 并且其派生类如果是非抽象的, 则必须实现接口的所有方法. 抽象类的派生类必须继承其所有抽象方法, 并且其派生类如果是非抽象的, 则必须实现抽象类的所有抽象方法.3. 接口抽象化更高, 接口的方法全是抽象方法, 而抽象类中的方法可以有抽象方法也可以有非抽象方法. 另外, 接口还不能有字段成员.4. 如果派生类既继承了类又继承了接口, 则定义时先写基类再写接口. 如: class creditcard : bankcard,Iloa 阅读全文
posted @ 2012-11-29 15:30 streetpasser 阅读(280) 评论(0) 推荐(0)
摘要: using System;using System.Collections.Generic;using System.Text;namespace ConsoleApp{ class operatorSample { //public static void Main() //{ // //重载操作符test // operatorTest ot = new operatorTest(); // ot.Run(); // Console.Read(); //} ... 阅读全文
posted @ 2012-11-29 15:17 streetpasser 阅读(310) 评论(0) 推荐(0)
摘要: 1. 密封类 即不希望类被继承,无派生类。 密封方法 即不允许被重载的方法。2. 密封方法 所在的类 不一定是密封类 (和抽象方法不同) , 该类的派生类中必须原封不动的继承这个密封方法. 密封方法本身也是个重载方法, 即 必须 sealed 和 override 都要有.3. 密封方法不能被重载(override), 但可以被覆盖(new).using System;using System.Collections.Generic;using System.Text;namespace ConsoleApp{ class sealedSample { public... 阅读全文
posted @ 2012-11-29 02:25 streetpasser 阅读(384) 评论(0) 推荐(0)