C# Decimal ToUInt16

Description

Decimal ToUInt16 converts the value of the specified Decimal to the equivalent 16-bit unsigned integer.

Syntax

Decimal.ToUInt16 has the following syntax.


[CLSCompliantAttribute(false)]
public static ushort ToUInt16(
  decimal value
)

Parameters

Decimal.ToUInt16 has the following parameters.

  • value - The decimal number to convert.

Returns

Decimal.ToUInt16 method returns A 16-bit unsigned integer equivalent to the value of value.

Example

The following example uses the ToUInt16 method to convert decimal numbers to UInt16 values.


using System;/*ww  w . j  a v  a 2s . c o  m*/

class Example
{
   public static void Main( )
   {
       ushort number = Decimal.ToUInt16(123.123M);
       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