有人可以用最简单的方式解释 VB.net 中的“mod”运算符吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39754657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:04:28  来源:igfitidea点击:

Can someone explain the 'mod' operator in VB.net in the simplest way possible?

vb.netoperators

提问by JoeS

I have this code I need to explain and the Mod operator has confused me, MSDN has a page on it and I cannot understand it clearly. I have included a section of code below if you could refer to it in your answer, thanks.

我有这段代码需要解释,但 Mod 操作员让我感到困惑,MSDN 上有一个页面,我无法清楚地理解它。如果您可以在答案中引用它,我在下面包含了一段代码,谢谢。

number1 = (input1/ 10) - 0.5
number2 = input2 Mod 10

Result = number1 + number2

回答by Michael Armes

Modin VB.NET is the Modulo operation. It returns the remainder when one number is divided by another.

Mod在 VB.NET 中是模运算。当一个数除以另一个数时,它返回余数。

For example, if you divided 4 by 2, your mod result would be 0 (no remainder). If you divided 5 by 2, your mod result would be 1.

例如,如果您将 4 除以 2,则您的 mod 结果将为 0(无余数)。如果您将 5 除以 2,则您的 mod 结果将为 1。

Explanation of the Modulo operation

模运算说明