【发布时间】:2015-04-20 11:18:56
【问题描述】:
所以我有这个代码:
class Program
{
static void Main(string[] args)
{
B b = new B();
A a = new A();
A c = new C();
I i = new I();
I k = new D();
J j = new E();
J d = new D();
Console.WriteLine(c is B); //this should be true
Console.WriteLine(i is J); //this should be false
Console.WriteLine(b is A); //this should be true
Console.WriteLine(d is A); //this should be false
Console.WriteLine(d is E); //this should be true
Console.WriteLine(k is E); //this should be true
Console.WriteLine(c is I); //this should be false
Console.ReadKey();
}
}
我需要建立一个适当的类层次结构,这样它才能工作,但我真的不知道如何>。>我知道它是关于继承的,但我无法编译它。
【问题讨论】:
-
你能告诉我们你的课程的代码吗?
-
欢迎来到stackoverflow。你试过什么了?阅读How to Ask。
-
我到目前为止:A类{}B类:A{}C类:B{}D类:I{}E类:J{}I类:J{}J类{ }
标签: c# class inheritance variable-assignment hierarchy