C#中的but操作员是否有C#空间?
即:
if (checkBox.Checked but comboBox.SelectedItem == null) { ... }
Run Code Online (Sandbox Code Playgroud)
而不是
if (checkBox.Checked == false || (checkBox.Checked && comboBox.SelectedItem != null)) { ... }
Run Code Online (Sandbox Code Playgroud)
还有哪些其他当前不存在的运算符可以用来节省输入不太可读的语句?
更新
KennyTM发布了一个很好的替代but我建议的运营商,但它有点错过了重点.我知道现有的运算符可以组合起来创建任何表达式,我只是想知道我的代码表达我的意图有多好.
即"如果该复选框未选中或没有选择"不扫描相当以及"如果复选框被选中,但什么也没有选择".
更新2:
对那些说"和"与"但"相同的人进行更新.虽然我同意逻辑上这是正确的(我不会重新打开这个问题)我想与你分享一个引用,这表明"和"和"但"之间的选择有时会产生很大的不同:
在我们的客户食堂吃了一顿咖喱午餐.看起来有点像猫病,但它很好吃.
Phil Winstanley - 2011年2月22日
非常感谢.:)
我正在使用一个Windows框,其中包含从以下网站ActiveState安装的最新版本的ActivePerl ,我遇到了一个非常简单的小于'<'概念的问题.
我有以下代码:
#!/usr/local/bin/perl
use warnings;
use strict;
my $a = 1;
if(1 < $a)
{
print "true";
}
Run Code Online (Sandbox Code Playgroud)
当我在命令提示符中执行脚本时,"true"永远不会打印出来.我在这里错过了什么简单的逻辑?我在C++,C#和java中多次使用过这个表达式,但由于某些原因它在这里不起作用.
如果我错过了简单的事情,请保持愉快.我花了很多时间想知道最新情况.
谢谢,
韦斯利
JavaScript中10/5和10%5之间的区别是什么?两者都一样吗?
我正在写一些条件,如果我想要有类似的东西
if ( /*condition one */) and or ( /* condition two */ )
Run Code Online (Sandbox Code Playgroud)
在C++中是否有这样的运算符以及如何编写它?
所以我想要类似的东西
if((( /* condition A */)&&(/* condition B */ ))|| /* AND OR? */ (( /* condition C */ )&&( /* condition D */)))
Run Code Online (Sandbox Code Playgroud)
(用于确定某个段的至少一侧是否属于另一个段)
所以...在c ++中有"AND OR",我们总是像这样编写UADLY CODE DUPLICATION:
if(((( /* condition A */)&&(/* condition B */ ))|| (( /* condition C */ )&&( /* condition D */))) || ((( /* condition A */)&&(/* condition B */ )) && (( /* condition C */ …Run Code Online (Sandbox Code Playgroud) 我不小心试过这个,编译!所以我想知道这可能是什么意思..谷歌没有帮助..
if (3 >+ 4)
dothis() //this is never hit btw..
if (3 >- 4)
dothis() //this is hit.
Run Code Online (Sandbox Code Playgroud)
两个代码编译btw ..
嘿家伙们想知道你是否可以帮我解决下面这段代码.我的程序正在输出一些奇怪的计算.
#include <iostream>
using namespace std;
int main()
{
int radius;
const double PI = 3.14159265;
float area;
float circumference;
cout << "Program to find the area and circumference of a circle\n\n\n";
cout << "Please enter the radius: ";
radius = cin.get();
area = PI * (radius * radius);
circumference = (2 * radius) * PI;
cout << "The area of your circle is " << area << ", the circumference of your circle is " << circumference <<"\n\n";
system("PAUSE"); …Run Code Online (Sandbox Code Playgroud) 我正在阅读Python/Pygame教程.我遇到了这个<-运营商.这是什么意思?
这是代码行:
if bullet[1]<-64 or bullet[1]>640 or bullet[2]<-64 or bullet[2]>480:
arrows.pop(index)
Run Code Online (Sandbox Code Playgroud) 在我正在阅读的一些代码中使用"<<",我无法找到有关它究竟是什么的任何文档.我认为这是某种有点明智的功能.
console.log(4<<3);
//This prints out 32.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
等号前的竖条是什么意思?如下面的代码:
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
Run Code Online (Sandbox Code Playgroud) operators ×10
c++ ×3
c# ×2
javascript ×2
.net ×1
c ×1
iostream ×1
perl ×1
python ×1
user-input ×1