我已经张贴相关的问题如下:转换多层次的for循环到LINQ或lambda表达式
replace 3 levels of nested for loops by efficient code possibly linq
但因为我不擅长使用LINQ或Lambda表达式..我不知道如何进一步扩展它。
我有一个稍微不同的3级嵌套for循环,我不知道如何将它转换成Linq或Lambda表达式..我一直在工作的任务是提出更有效的替代代码为linq或lambda表达式..请帮助。谢谢..
public static void CompareEntities(
out EntityCollection<StringResourceEntity> entitiesDifference,
EntityCollection<StringResourceEntity> entitiesLargerSet,
EntityCollection<StringResourceEntity> entitiesSmallerSet)
{
var diff = new EntityCollection<StringResourceEntity>();
string defaultCulture = LocalizationConfiguration.DefaultCulture;
foreach (StringResourceEntity entityLargerSet in entitiesLargerSet)
{
bool entityMatch = false;
foreach (StringResourceEntity entitySmallerSet in entitiesSmallerSet)
{
if (entityLargerSet.Key.Equals(entitySmallerSet.Key))
{
foreach (var stringResValSmall in entitySmallerSet.StringResourceValues)
{
if (stringResValSmall.Culture.Equals(defaultCulture) &&
stringResValSmall.Value.Length > 0)
{
entityMatch = true;
}
}
}
}
if (entityMatch == false)
{
diff.Add(entityLargerSet);
}
}
entitiesDifference = diff;
}
柯克,非常酷的答案..谢谢100万..我会回去打这些书,并确保我了解这一点,并建立它。再次感谢。 –