C#中Dictionary明明new过却提示未实例化
这两个类
public class Node{
public Dictionary<int, int> toList;
public Dictionary<int, LineInfo> lineList;
public Node(){
toList=new Dictionary<int,int>();
lineList=new Dictionary<int,LineInfo>();
}
}
public class LineInfo{
public int nextNode;
public int linkID;
public LineInfo(int _nextNode, int _linkID)
{
nextNode = _nextNode;
linkID = _linkID;
}
}
Node[] nodeList = new Node[nodeNum]; //node数组初始化
然后这句报错,不知道什么原因
nodeList[i].lineList.Add(tempLineID, new LineInfo(tempStopID,tempLinkID));