将值传递给字典 [英] Passing value to a dictionary
本文介绍了将值传递给字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个词典,比如
Dictionary<double, double> Draw = new Dictionary<double, double>();
Draw.Add(7.781,2.96);
Draw.Add(7.578, 3.640);
Draw.Add(7.5,4.358);
Draw.Add(7.625,5.109);
Draw.Add(7.578,5.765);
Draw.Add(7.546,6.484);
Draw.Add(7.5,7.140);
Draw.Add(7.546,7.859);
Draw.Add(7.5,8.609);
foreach (KeyValuePair<double, double> drop in Draw)
{
Shape conductorCable12shape = panelSheet.Drop(conductorCable12, "Key = {0}, Value = {1}");
}
但是这里我怎么能传递值,因为Conductorcable12已修复,我必须通过2参数。
But here how can i pass the values as Conductorcable12 is fixed and i have to pass 2 arguments.
推荐答案
试试这个:
Try this:
Shape conductorCable12shape = panelSheet.Drop(conductorCable12, String.Format("Key = {0}, Value = {1}", drop.Key, drop.Value));
String.Format
格式化串;它用键取代 {0}
,用值取代 {1}
。
编辑:你在评论中说它需要3个参数。试试这个:
String.Format
formats the string; it replaces the {0}
with the key and {1}
with the value.
you said in your comment that it takes 3 arguments. Try this:
Shape conductorCable12shape = panelSheet.Drop(conductorCable12, drop.Key, drop.Value);
这篇关于将值传递给字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文