有没有办法将以下 3 级嵌套 for 循环替换为更高效或更简洁的代码?linq 是否能够使其更高效且易于阅读?
请帮忙。谢谢
bool myMatch = false;
foreach (MyEntityClass entitySmallerSet in entitiesSmallerSet)
{
if (entityLargerSet.Key.Equals(entitySmallerSet.Key))
{
foreach (var stringResValLarge in entityLargerSet.StringResourceValues)
{
foreach (var stringResValSmall in entitySmallerSet.StringResourceValues)
{
if (stringResValSmall.Culture.Equals(stringResValLarge.Culture)
&& stringResValSmall.Value.Equals(stringResValLarge.Value))
{
myMatch = true;
}
}
}
}
}