给出格式异常
本文关键字:异常 格式 | 更新日期: 2023-09-27 18:17:43
输入字符串格式不正确。
public List<int> GetNodeIDInfo()
{
nodeData_List = this.GetNodeInfo();
for(int iNode = 0; iNode<nodeData_List.Count; iNode++)
{
string[] str = nodeData_List.ElementAt(0);
foreach (string s in str)
{
nodeID_List.Add(Convert.ToInt32(s));
}
}
return nodeID_List;
}
这有什么不对?
看以下内容:
//this variable is for saving results
Dictionary<int,double> memberLengthMap = new Dictionary<int,double>();
Dictionary<int, Tuple<double, double, double>> nodes = GetNodeID_AlongWithCoordinates();
Dictionary<int, Tuple<int,int>> members = GetMemberID_AlongWithStartandEndNode();
foreach(KeyValuePair<int, Tuple<int,int>> member in members)
{
Tuple<double, double, double> startNode = nodes[member.Value.Item1];
Tuple<double, double, double> endNode = nodes[member.Value.Item2];
double xDiff = (startNode.Item1 - endNode.Item1);
double yDiff = (startNode.Item2 - endNode.Item2);
double zDiff = (startNode.Item3 - endNode.Item3);
double distance = Math.Sqrt(xDiff*xDiff + yDiff*yDiff + zDiff*zDiff);
memberLengthMap.Add(member.Key,distance);
}
希望对你有所帮助