【问题标题】:How to enforce c# 10's static interface properties to be implemented?如何强制实现 c# 10 的静态接口属性?
【发布时间】:2021-09-11 10:39:23
【问题描述】:

c# 10 的静态接口属性显然是自动实现的。如何强制覆盖它?

    public interface IModelLogicEventSubsciptions
    {
        static EventSubscriptionType EventSubscriptions { get; }
    }
    public interface AnyClass : IModelLogicEventSubsciptions
    {
        //static EventSubscriptionType EventSubscriptions { get; }
    }

【问题讨论】:

    标签: c# c#-10.0


    【解决方案1】:

    解决方法是将接口成员标记为抽象

    public interface IModelLogicEventSubsciptions
    {
        static abstract EventSubscriptionType EventSubscriptions { get; }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 2013-02-27
      • 2016-01-28
      • 1970-01-01
      • 2012-06-14
      • 1970-01-01
      相关资源
      最近更新 更多