代码之家  ›  专栏  ›  技术社区  ›  Jörg W Mittag

C语言中的“强制”重写#

c#
  •  3
  • Jörg W Mittag  · 技术社区  · 17 年前

        public virtual string Description
        {
            get { throw new NotImplementedException(); }
        }
    
        public virtual string ErrorMessage
        {
            get { throw new NotImplementedException(); }
        }
    

    2 回复  |  直到 17 年前
        1
  •  16
  •   Winston Smith    17 年前

    创建属性(这些不是示例中的方法) abstract

    public abstract string Description{ get; }
    
    public abstract string ErrorMessage{ get; }
    
        2
  •  3
  •   Rashmi Pandit    17 年前

    在使用方法的情况下,你应该把它们抽象化

    public abstract void Method();