C#中多集合组合实现
2021-03-27 02:24
标签:ret ctp list func inf each long class ble C#中多集合组合使用方法,主要用到 Enumerable.Join方法 关键代码: C#中多集合组合实现 标签:ret ctp list func inf each long class ble 原文地址:https://www.cnblogs.com/yangyuping/p/9365242.htmlvar skuInfoList = new Dictionaryint, Listlong>>();
var ctParamList = new Listlong>();
foreach (var sku in skuList)
{
var singleSku = sku.Split(‘|‘);
ctParamList = new Listlong>();
foreach (var skuParam in skuParamList)
{
var singleSkuParam = skuParam.Split(‘:‘);
if (singleSku[0] == singleSkuParam[0])
{
var singleParam = singleSkuParam[1].Split(‘|‘);
ctParamList.Add(Convert.ToInt64(singleParam[0]));
}
}
skuInfoList.Add(Convert.ToInt32(singleSku[0]), ctParamList);
}
var res = new List
long>>() { new Listlong>() };
Func
long>, List
long>>> func = lst =>
{
return res.Join(lst, x => 1, x => 1, (x, y) =>
{
var tem = x.ToList();
tem.Add(y);
return tem;
}).ToList();
};
foreach (var skuInfo in skuInfoList)
res.AddRange(func(skuInfo.Value));
var res = new List
long>>() { new Listlong>() };
Func
long>, List
long>>> func = lst =>
{
return res.Join(lst, x => 1, x => 1, (x, y) =>
{
var tem = x.ToList();
tem.Add(y);
return tem;
}).ToList();
};
下一篇:c#源码如何生成托管代码块