很可惜,你离最终答案就差最后一步了。
在 C# 中静态成员可以是抽象或者虚拟的,因此你只需要把你的 Creature 类型换成接口类型,然后把 LegNum 这个静态属性定义在接口中,并设置为抽象成员即可。
首先创建一个 ICreature 接口类型:interface ICreature { abstract static int LegNum { get; set; } } 然后在你的 Ant、Octopus、Centipede 类型中实现这个接口: class Ant : ICreature { public static int LegNum { get; set;…。
以色列是如何从三天前的不可一世要灭了伊朗到今天的哭哭啼啼要“为生存而战”的?
We are ready to answer your questions.