0

使用 Resharper 7.1,C#

我有一门Apple基于Fruit

public partial class Apple: Fruit, IEat

使用命令Refactor/Pull Members Up,如何将Fruit.Eat()方法添加到接口?

Resharper UI 只允许我添加Apple成员。

4

1 回答 1

0

The code above (where Apple inherits from both Fruit and IEat) is redundant. I think how you want it is that Apple inherits from Fruit

public class Apple : Fruit

and Fruit inherits from IEat

public class Fruit : IEat

If Fruit inherits from IEat as I have suggested here, then you should be able to do the Resharper "pull members up" from the Fruit class.

If Fruit doesn't inherit from IEat, you can't do the refactoring.

于 2014-03-13T15:23:08.990 回答