Midnight Beach is Jon Shemitz, a freelance programmer and author.
Jon offers software consulting and contract services, and recently finished his 2nd book -
.NET 2.0 for Delphi Programmers.
On Sun, 22 May 2005 15:53:19 -0500, gh <gh@at.ne> wrote:
[color=blue]
>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[/color]
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.Div Rem which does
both the division & the remainder in one statement.
Hope this helps
Jay
"gh" <gh@at.ne> wrote in message
news:eg9YLBxXFH A.3184@TK2MSFTN GP15.phx.gbl...
|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
Comment