【问题标题】:Resharper: Pull Members Up from base class?Resharper:从基类中拉出成员?
【发布时间】:2013-02-05 23:51:14
【问题描述】:

使用 Resharper 7.1,C#

我有一个基于Fruit 的课程Apple

public partial class Apple: Fruit, IEat

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

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

【问题讨论】:

  • 请添加更多详细信息。也许您需要提取接口重构?或者您需要从 Fruit 类而不是 Apple 调用 Refactoring?
  • 这里没有接口??

标签: c# resharper resharper-7.1


【解决方案1】:

上面的代码(Apple 继承自 FruitIEat)是多余的。我想你想要的是Apple继承自Fruit

public class Apple : Fruit

Fruit 继承自IEat

public class Fruit : IEat

如果Fruit 继承自IEat,正如我在这里所建议的那样,那么您应该能够从 Fruit 类中执行 Resharper“拉取成员”。

如果Fruit 不继承自IEat,则无法进行重构。

【讨论】:

    猜你喜欢
    • 2011-06-20
    • 1970-01-01
    • 1970-01-01
    • 2021-02-09
    • 2022-11-30
    • 2018-10-05
    • 2013-03-10
    • 2013-02-12
    • 2013-12-19
    相关资源
    最近更新 更多