有关C#OR运算符的问题 [英] Question about the C# OR operator

查看:70
本文介绍了有关C#OR运算符的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮帮我吗?我试图找到执行类似OR的代码,例如:

Can some one please help me out? I am trying to find code that does something like an OR, for example:

if (textbox1.text = "lol") or (textbox2.text = "l33t")
{
    label1.text = "I play wow";
}



在或"部分中,我知道 or 不是真正的关键字或其他任何东西,但是它是什么代码?是"||"吗?有人可以帮我吗?



In the ''or'' section, I know that or is not a real keyword or anything, but what code is it? Is it ''||''? Can anyone please help me?

推荐答案

if((textbox1.text == "lol") || (textbox2.text == "l33t"))
{
label1.text = "I play wow";
}


尝试"|"字符:一个是二进制"OR"或加倍它是逻辑"OR":
Try the ''|'' character: a single one is binary "OR" or doubled up it is logical "OR":
if ((textbox1.Text == "lol") || (textbox1.Text == "l33t"))
   {
   ... execute only if textbox1.Text is either string
   }


int i = 1 | 2;
Console.WriteLine(i.ToString());

会产生"3":即1个二进制数与2进行或运算

Would produce "3": i.e. 1 binary ORed with 2


为什么不花一些时间 ^ ](及更高版本)?
Why not spend some time here[^] (and above) before embarking on your development?


这篇关于有关C#OR运算符的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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