【发布时间】:2014-08-13 06:53:57
【问题描述】:
我有nodeID_List; nodeX_List; nodeY_List ; nodeZ_List;这些列表,第一个是整数列表,其他三个是双精度列表。如何创建一个字典,其中键将是列表中的每个 int 并且 3 个双精度值将是键的值。我尝试使用元组,但无法正确格式化。
Tuple<int, double, double, double> tuple_NodeData;
nodeData_List = this.GetNodeInfo();
nodeID_List = this.GetNodeIDInfo();
nodeX_List = this.GetNodeXInfo();
nodeY_List = this.GetNodeYInfo();
nodeZ_List = this.GetNodeZInfo();
for (int iNode = 0; iNode < nodeData_List.Count; iNode++)
{
tuple_NodeData = new Tuple<int, double, double, double>
(nodeID_List[iNode], nodeX_List[iNode], nodeY_List[iNode], nodeZ_List[iNode]);
}
【问题讨论】:
-
您的代码应该可以工作(您可能希望从值中删除键)。你只需要将它添加到字典中
标签: c# list dictionary