Math.DivRem calculates the quotient of integers and returns the remainder in an output parameter.
using System; public class Example { public static void Main() { int[] dividends = { 1, 0, -1, Int32.MinValue }; int[] divisors = { 2000, -2000 }; foreach (int divisor in divisors) { foreach (int dividend in dividends) { int remainder; int quotient = Math.DivRem(dividend, divisor, out remainder); Console.WriteLine(@"{0:N0} \ {1:N0} = {2:N0}, remainder {3:N0}", dividend, divisor, quotient, remainder); } } } }