运算符"=="不能应用于“方法组"和“字符串"类型的操作数 [英] Operator '==' cannot be applied to operands of type 'method group' and 'string'

查看:299
本文介绍了运算符"=="不能应用于“方法组"和“字符串"类型的操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此代码第三行收到无法将运算符'=='应用于'方法组'和'字符串'类型的操作数"错误,我不知道为什么.

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")))

起初我以为也许它不喜欢"==",所以我用"="修改了它,但这不是问题.此外,它上方的那一行使用"==",并且工作正常. Glseg是表中的字段,而不是方法,因此它一定不能喜欢字符串.有谁知道我要去哪里错了?

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?

推荐答案

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

In C#, those methods have to be called with ():

str.TrimStart() == "bla"

这篇关于运算符"=="不能应用于“方法组"和“字符串"类型的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆