我有Node
课程:
public class Node
{
public ObservableCollection<Node> Childs {get;set;}
//some other properties
}
和派生类NodeSimple:
public class NodeSimple:Node
{
public new ObservableCollection<Node> Childs {get;set;}//do some work
}
然后我有节点列表:
List<Node> nodeList=GetNodes();
我希望将其转换为NodeSimple列表:
List<NodeSimple> simpleList=new List<NodeSimple>();
foreach(var node in nodeList)
simpleList.Add(node as NodeSimple);
但我在node as NodeSimple
取消了
我做错了什么?
我只想转换它。
谢谢!