-8

我开始在 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;
4

1 回答 1

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();
于 2013-03-13T19:24:23.077 回答