和运营商不能与布尔和字符串工作 [英] AND Operator cannot work with bool and string

查看:165
本文介绍了和运营商不能与布尔和字符串工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里,我用两个标准,一个LINQ2SQL语句:

I have a LINQ2SQL statement where I am using two criteria:

var query1 = from r in dt.Test
                                where r.ID == 92 
                                && r.Status = '"I"
                                select r.ID && r.Status = "I"



但它给我一个迷途AND(安培;&安培;)运营商不能用字符串和布尔工作。请告诉我周转此?

But its giving me an err that AND (&&) operator cannot work with string and bool. Whats the turnaround for this?

推荐答案

试着用替换你的 = 迹象 ==

var query1 = from r in dt.Test
                            where r.ID == 92 
                            && r.Status == "I"
                            select r.ID && r.Status == "I"



记住 = 在C#是赋值运算符,而 == 是平等的运营商。正如有人谁C#和VB.NET之间定期翻转,我常来这儿脱胶!

Remember that = in C# is the assignment operator, and == is the equality operator. As someone who regularly flips between C# and VB.NET, I often come unstuck here!

这篇关于和运营商不能与布尔和字符串工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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