Dividing\Remainder

  • Thread starter Thread starter gh
  • Start date Start date
G

gh

I am dividing var1 by var2 and I want to check and see if there is a
remainder. How do I do this in C#?

TIA
 
I am dividing var1 by var2 and I want to check and see if there is a
remainder. How do I do this in C#?

TIA

Use the modulus (%) operator:

int var1 = 7;
int var2 = 4;

int quotient, remainder;

quotient = var1 / var2;

remainder = var1 % var2;


HTH

rossum



The ultimate truth is that there is no ultimate truth
 
gh,
In addition to the % operator, you can use System.Math.DivRem which does
both the division & the remainder in one statement.

Hope this helps
Jay

|I am dividing var1 by var2 and I want to check and see if there is a
| remainder. How do I do this in C#?
|
| TIA
 
Back
Top