C# Math DivRem(Int32, Int32, Int32)

Description

Math DivRem(Int32, Int32, Int32) calculates the quotient of two 32-bit signed integers and also returns the remainder in an output parameter.

Syntax

Math.DivRem(Int32, Int32, Int32) has the following syntax.


public static int DivRem(
  int a,/*from   w  w  w. j  av a 2s  .c o  m*/
  int b,
  out int result
)

Parameters

Math.DivRem(Int32, Int32, Int32) has the following parameters.

  • a - The dividend.
  • b - The divisor.
  • result - The remainder.

Returns

Math.DivRem(Int32, Int32, Int32) method returns The quotient of the specified numbers.

Example

The following example demonstrates the DivRem(Int32, Int32, Int32) method.


/*from   w w  w  . j  a  v a  2  s.  co m*/
using System;

public class Example
{
   public static void Main()
   {
            int remainder; 
            int quotient = Math.DivRem(1, 3, out remainder);
            Console.WriteLine(quotient);
            Console.WriteLine(remainder);
         
                                
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version