1

我需要覆盖嵌套界面中的一些属性。我试试看:

public interface INode {
    INode Parent { get; }
    ICollection<INode> Items { get; }
    Boolean IsKey { get; }
    String Name { get; set; }
    Object Value { get; set; }
    Boolean IsValidValue(Object value);
    Boolean HasFixedValues { get; }
    ICollection<Object> FixedValues { get; }
    String Description { get; set; }
    String GetFullPath();
    Boolean IsExists();
    INode GetFromXML(XElement xml);
    XElement WriteToXml();
}

public interface INode<T> : INode {       
    new T Value { get; set; }
    new Boolean IsValidValue(T value);
    new ICollection<T> FixedValues { get; }
}

但我得到编译错误。我该怎么做?

异常消息:

来自程序集“AcadInfo_Accessor,版本=0.0.0.0,文化=中性,PublicKeyToken=null”的类型“AndreyBushman.AutoCAD.INode_Impl 1' from assembly 'AcadInfo_Accessor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. TestProject Error 22 The "BuildShadowTask" task failed unexpectedly. System.TypeLoadException: Method 'set_Value' in type 'AndreyBushman.AutoCAD.INode_Impl1”中的错误 21 方法“set_Value”没有实现。

4

1 回答 1

0

实现此接口时,请确保同时实现成员 fromINode和 from INode<T>

class Test : INode<int>
{
    public int Value {
        get {
            throw new NotImplementedException();
        }
        set {
            throw new NotImplementedException();
        }
    }

    object INode.Value {
        get {
            throw new NotImplementedException();
        }
        set {
            throw new NotImplementedException();
        }
    }
}
于 2012-12-25T13:23:04.310 回答