2012-12-25 29 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(); 
     } 
    } 
}