C# Decimal ToInt32

Description

Decimal ToInt32 converts the value of the specified Decimal to the equivalent 32-bit signed integer.

Syntax

Decimal.ToInt32 has the following syntax.


public static int ToInt32(
  decimal d
)

Parameters

Decimal.ToInt32 has the following parameters.

  • d - The decimal number to convert.

Returns

Decimal.ToInt32 method returns A 32-bit signed integer equivalent to the value of d.

Example

The following example uses the ToInt32 method to convert decimal numbers to Int32 values.


/*w w w .  jav  a2  s  .  c  o m*/
using System;

class Example
{
   public static void Main( )
   {
      int number = Decimal.ToInt32(123.999m);
      Console.WriteLine(number);       

   }
}

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