Translate to LINQ
本文关键字:LINQ to Translate | 更新日期: 2023-09-27 18:03:58
我开始用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;
试试这个:
return (
from div in strExport.Split(chrDivSep)
from item in div.Split(chrItemSep)
where String.Equals(item.Split(chrCoupleSep)[0], "table", StringComparison.OrdinalIgnoreCase)
).Any();