我开始在linq中重写以下代码但没有用。你能帮我解释一下这个表达吗?
bool bReturn = false;
string[] divs = strExport.Split(chrDivSep);
// bReturn = divs.Any(D => D.Split(chrItemSep).Any(C => C.Split(chrCoupleSep)[0].ToUpper() == "TABLE"));
foreach (string strdiv in divs)
{
string[] items = strdiv.Split(chrItemSep);
foreach (string item in items)
{
string[] couple = item.Split(chrCoupleSep);
switch (couple[0].ToUpper())
{
case "TABLE":
// There is a non constant field
bReturn = true;
break;
}
if (bReturn)
break;
}
if (bReturn)
break;
}
return bReturn;
答案 0 :(得分:1)
试试这个:
return (
from div in strExport.Split(chrDivSep)
from item in div.Split(chrItemSep)
where String.Equals(item.Split(chrCoupleSep)[0], "table", StringComparison.OrdinalIgnoreCase)
).Any();