这两个类
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;
}
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));
解决方案
10
Node[] nodeList = new Node[nodeNum]; //node数组初始化
你这只是初始化了一个数组
nodeList[i]为null
你这只是初始化了一个数组
nodeList[i]为null
10
nodeList[i]这句报错,不是你的lineList报错,你初始化了数组,数组默认值是default(Node),null的干活