我有最新的字典测试dict:
Dictionary<int, Tuple<int, string, string>> testdict
基本上是
Dictionary<autoID, Tuple<ignore, "shortcode", "product_name">>
例子:
testdict.Add(1, new Tuple<int, string, string>(1, "555", "Light Blue"));
testdict.Add(2, new Tuple<int, string, string>(2, "122", "Majenta Red"));
testdict.Add(3, new Tuple<int, string, string>(2, "133", "Dark Yellow"));
testdict.Add(4, new Tuple<int, string, string>(1, "555", "Light Blue"));
testdict.Add(5, new Tuple<int, string, string>(1, "555", "Light Blue"));
testdict.Add(6, new Tuple<int, string, string>(2, "133", "Dark Yellow"));
testdict.Add(7, new Tuple<int, string, string>(2, "766", "Purple"));
我需要一个具有此格式的新容器:
autoid, "shortcode" group, "product_name" group, "count"
短代码和产品名称总是匹配的,所以它们可以同时分组或分组,并选择第二个的任何出现(例如,第一个)。
可以忽略int键(它只是创建一个订单)。
元组中的int也将被忽略。
我需要的新容器的一个例子是:
Dictionary<int, Tuple<string, string, int>> newdict
newdict.Add(AutoID_Order, new Tuple<string, string, int>("shortcode", "product_name", count)); (structure)
newdict.Add(1, new Tuple<string, string, int>("555", "Light Blue", 3));
newdict.Add(2, new Tuple<string, string, int>("133", "Dark Yellow", 2));
newdict.Add(3, new Tuple<string, string, int>("122", "Majenta Red", 1));
newdict.Add(4, new Tuple<string, string, int>("766", "Purple", 1));
我怎样才能做到这一点?LINQ可以接受。