C#中 抽象类,接口是不能被实例化,那怎么使用,最好举个例子,谢谢!

com.steptools.schemas.config_control_design.Closed_shell close1 = new com.steptools.schemas.config_control_design.Closed_shell();
这种new的方式不对,应该怎么样?

抽象类和接口都不可以被实例化,但是接口可以引用。例如有一个实现了IPrintable 的 AA类,虽然不可以创建起对象,但可以这样做:
IPrintable xxx = new AA();
在这里 xxx就叫做引用,在这个例子中就是指某个AA对象
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-08-08
人 ren = new 超人();
人 ren = new 傻人();
人 ren = new 小人();

基类 变量 = new 派生类();
接口 变量 = new 派生类();本回答被网友采纳
第2个回答  2013-08-08
继承啊,新写个类继承接口,然后实现接口中的函数
相似回答