[DataContract]
public class UniqueNamedItem
{
[DataMember]
int Id { public get; protected set; }
[DataMember]
string Name { public get; protected set; }
}
[KnownType(typeof(UniqueNamedItem))]
[DataContract]
public class BasicNode : UniqueNamedItem
{
[DataMember]
SortedList<string, BasicNode> Children { public get; private set; }
public void addChild(BasicNode bn)
{
this.Children.Add(bn.Name, bn);
}
}
你能告诉我为什么在我的 addChild 函数中对 bn.Name 的调用无效,即使 UniqueNamedItem.Name 属性具有公共 get 访问器?