【发布时间】:2014-09-12 07:33:01
【问题描述】:
this question 的回答说“你没有创建接口的实例..”我想知道这是不是真的。
谁能告诉我谁的实例是在下面的代码行中创建的?为什么?
BaseClass b= new Child();
和
BaseInterface bi= new Child();
编辑:我问的是 C#.net 语言。如果实例是由 child() 创建的。为什么visual studio的intellisense在按下时会显示Base成员?
【问题讨论】:
-
它的 c# 代码。 Child 派生自 BaseClass(Class) 以及 BaseInterface(Interface)。
-
new Child()实际创建;然后它被访问为BaseInterface -
@Akie 我相信你需要更多地学习 OOP。学习 OOP 可以很容易地回答这个问题。请不要误解我的意思:这是一个过于基本的问题。
标签: c# oop inheritance interface