我需要覆盖嵌套接口中的一些属性。我试试看:
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,Version = 0.0.0.0,Culture = neutral, PublicKeyToken = null'没有实现。
答案 0 :(得分:0)
实施此界面时,请务必同时实施INode
中的成员和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();
}
}
}