2012-12-25 31 views
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; } 
} 

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

异常消息:

错误 型21方法 'SET_VALUE' '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_Impl 1' 从组件 “AcadInfo_Accessor,版本= 0.0.0.0,文化=中性, 公钥= null'没有实现。

+5

它与我编译 –

+1

能告诉你这些接口的实现代码。问题不在接口的声明中。 – horgh

+0

我还没有写实现。只有这些接口。 –

回答

0

当实现了这个接口,确保你从INode<T>同时实现从INode成员和一个:

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(); 
     } 
    } 
}