4

I am receiving an "Operator '==' cannot be applied to operands of type 'method group' and 'string'" error on the third line of this code and I do not know why.

where (PRIORITiesItem.Prioid == null || PRIORITiesItem.Prioid.Contains("1%")) 
    && (SITEItem.Id == "TH" || SITEItem.Id == "NM")  
--> && (sv.Glseg.TrimStart == "703" || sv.Glseg.TrimStart == "704" || sv.Glseg.TrimStart == "705")        
    && (CREWItem.Crewid == null || !CREWItem.Crewid.Contains("2-%") && CREWItem.Crewid.Contains("MAINT") 
        || (CREWItem.Crewid.Contains("ELECT") || CREWItem.Crewid.Contains("INST")
    && !WORKORDERTYPEItem.Id.Contains("Standing")))

At first I thought that maybe it didn't like "==" so I chnaged it with "=" but that wasn't the problem. besides, the line right above it uses "==" and it works just fine. Glseg is a field within a table, not a method so it must not like the string. Does anyone have any ideas where I am going wrong?

4

1 回答 1

22

在 C# 中,必须使用以下方法调用这些方法()

str.TrimStart() == "bla"
于 2012-06-11T18:26:59.447 回答