C# 中 /= 是什么意思?
我在谷歌上搜索 /=
时遇到了困难...谁能告诉我这段代码的作用吗?
number = digits[n % digits.Length] + number;
n /= digits.Length;
我的目的是确定此操作的其余部分是什么......这样我就知道何时停止或继续进行。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是除法赋值运算符,含义
n = n/digits.Length
请参阅MSDN:/= 运算符(C# 参考) 了解详细信息。
This is the division assignment operator operator meaning
n = n/digits.Length
See MSDN: /= Operator (C# Reference) for details.
只是为了添加已在各种答案中发布的内容,复合赋值运算符
$=
(将$
替换为二元运算符)类似到右侧使用的二元运算符的赋值。不同之处在于左侧仅计算一次。因此:x
仅计算一次。x
被评估两次。在实践中不太可能产生影响。
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
is evaluated only once.x
is evaluated twice.Unlikely to make a difference in practice.
x /= y
表示设置 x 等于(在本例中为整数部分)“x 除以 y”
。/
是除法运算符。x /= y
meansset x equal to (in this case the integral part of) 'x divided by y'
./
is the division operator.和刚才的除法一样
。
Same as
just division.
根据 MSDN,这两个是等效的:
并且
与更常见的类似:
Per MSDN, these two are equivalent:
and
Similar to the more commonly seen:
/=
是除法运算符。与说的是同一件事:
/=
is a division operator.is the same thing as saying: