How can I calculate division and modulo for integer numbers in C#?
Here's an answer from the MSDN documentation.
When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2. To determine the remainder of 7 / 3, use the remainder operator (%).
int a = 5; int b = 3; int div = a / b; //quotient is 1 int mod = a % b; //remainder is 2
1.4m articles
1.4m replys
5 comments
57.0k users