[英]What does /= mean in C#?
I am having a tough time googling /=
... can anyone tell me what this code does? 我正在艰难地搜索/=
...有人能告诉我这段代码的作用吗?
number = digits[n % digits.Length] + number;
n /= digits.Length;
My intent is to determine what the remainder of this operation is... so I know when to stop or keep going. 我的目的是确定这个操作的剩余部分是什么......所以我知道何时停止或继续前进。
This is the division assignment operator operator meaning n = n/digits.Length
这是除法赋值运算符运算符,意思是n = n/digits.Length
See MSDN: /= Operator (C# Reference) for details. 有关详细信息,请参阅MSDN:/ =运算符(C#参考) 。
Just to add to what has already been posted in various answers, a compound assignment operator $=
(replace $
with a binary operator) is similar to an assignment with the binary operator used in the right-hand side. 只是为了添加已经在各种答案中发布的内容,复合赋值运算符$=
(用二元运算符替换$
) 类似于右侧使用二元运算符的赋值。 The difference is that the left-hand side is evaluated only once. 不同之处在于左侧仅评估一次。 So: 所以:
x $= y
x
is evaluated only once. x
仅评估一次。
x = x $ y
x
is evaluated twice. x
被评估两次。
Unlikely to make a difference in practice. 不太可能在实践中有所作为。
x /= y
means set x equal to (in this case the integral part of) 'x divided by y'
. x /= y
表示set x equal to (in this case the integral part of) 'x divided by y'
。 /
is the division operator. /
是分部运营商。
Same as 如同
n += 4; // adds 4
n *= 4; // 4 times
just division. 只是分裂。
/=
is a division operator. /=
是一个除法运算符。
x /= y ;
is the same thing as saying: 与说法是一回事:
x = x / y ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.