【发布时间】:2014-08-07 10:52:38
【问题描述】:
任何人都可以帮助以下列表元组超过 8 个元素不起作用:
List<Tuple<int, string, double, string, int, string, double, Tuple<int, string>>> tpl = new
List<Tuple<int, string, double, string, int, string, double, Tuple<int, string>>>();
tpl.Add(Tuple.Create(1, "ABC", 100.123, "XYZ", 1, "ABC", 100.123, new Tuple<int, string>(100, "My Rest Item")));
foreach(var k in tpl)
listBox1.Items.Add(k.Item1.ToString() + " ---> " + k.Item2.ToString() + " ---> " + k.Item3.ToString() + " ---> " +
k.Item4.ToString() + " ---> " + k.Item5.ToString() + " ---> " + k.Item6.ToString() + " ---> " +
k.Item7.ToString() + " ---> " + k.Rest.Item1.ToString());
它给出以下错误
错误 1 最好的重载方法匹配 '
System.Collections.Generic.List<System.Tuple<int,string,double,string,int,string,double,System.Tuple<int,string>>>.Add(System.Tuple<int,string,double,string,int,string,double,System.Tuple<int,string>>)' 有一些无效参数 C:\Users\Hewlett Packard\AppData\Local\Temporary 项目\WindowsFormsApplication1\Form1.cs 68 17 WindowsFormsApplication1 和错误 2 参数 1:无法从 'System.Tuple<int,string,double,string,int,string,double,System.Tuple<System.Tuple<int,string>>>' 到 'System.Tuple<int,string,double,string,int,string,double,System.Tuple<int,string>>' C:\Users\Hewlett Packard\AppData\Local\Temporary 项目\WindowsFormsApplication1\Form1.cs 68 25 WindowsFormsApplication1
【问题讨论】:
-
除此之外 - 不要这样做!使用相关属性等创建您自己的命名类型。