【发布时间】:2014-03-06 17:03:18
【问题描述】:
我有以下收藏
var collection = new []
{
"First1",
"Second2",
"Third12"
}
然后我有一个查找表,其中包含需要替换的键:
var keys = new []
{
Tuple.Create(1, "ABC"),
Tuple.Create(2, "DEF")
}
最终结果应该是从查找表中替换值的原始列表
var collection = new []
{
"FirstABC",
"SecondDEF",
"ThirdABCDEF"
}
我正在尝试通过以下方式使用聚合函数:
string[] collection = new[]{"First#", "Second@"};
Console.WriteLine("Before {0}", String.Join(" - ", collection));
var keys = new[]{Tuple.Create("#", "ABC"),Tuple.Create("@", "CDE")};
foreach ( var item in collection)
{
if() // my item is in any occurrence of the keys array
}
Console.WriteLine("After {0}", String.Join(" - ", collection));
【问题讨论】: