var productNameTags = document.DocumentNode.SelectNodes(textBox3.Text);
var priceTags = document.DocumentNode.SelectNodes(textBox2.Text);
var codeNameAndPrice = productNameTags.Zip(priceTags, (n, w) => new { productNameTags = n, priceTags = w });
int counter = 1;
if (codeNameAndPrice != null)
{
foreach (var nw in codeNameAndPrice)
{
label1.Visible = true;
label1.Text += counter + ". " + nw.productNameTags.InnerHtml + " - " + nw.priceTags.InnerHtml + "\n";
}
}
我有这样的代码看起来在HTML标签和打印出产品名称,并从网站上的价格,并打印出像这样使用.ZIP:Enumerable.Zip多于2个集合?
- 棒球 - £5.00
- 足球 - £10.00
- 玩具车 - £15.00
是否有使用不同的方法将三个或更多的变量来压缩在一起的一个简单的方法?
例如
- 棒球 - £5.00 - 1123
- 足球 - £10.00 - 1124
- 玩具车 - £15.00 - 1125
提前感谢!
你可以连'Zip'命令 - 哪里来的1123,1124,和1125从何而来? –
[邮编ÑIEnumerable的的可能的复制š一起?同时在它们之间迭代?(http://stackoverflow.com/questions/3989319/zip-n-ienumerablets-together-iterate-over-them-simultaneously) –
这两个问题@RegEdit期望的结果是不同的,所以我我不知道它应该是重复的......另一方面,答案可以用来回答这个问题......所以把我的金锤放在口袋里而不是关闭。上使用索引合并(对于相同长度的序列)的能力 –