C# BigInteger Explicit(BigInteger to UInt16)
Description
BigInteger Explicit(BigInteger to UInt16)
Defines
an explicit conversion of a BigInteger object to an unsigned 16-bit integer
value.
Syntax
BigInteger.Explicit(BigInteger to UInt16)
has the following syntax.
public static explicit operator ushort (
BigInteger value
)
Parameters
BigInteger.Explicit(BigInteger to UInt16)
has the following parameters.
value
- The value to convert to an unsigned 16-bit integer.
Returns
BigInteger.Explicit(BigInteger to UInt16)
method returns An object that contains the value of the value parameter
Example
/*from w ww.j a v a2 s. c o m*/
using System;
using System.IO;
using System.Numerics;
public class Example
{
public static void Main()
{
BigInteger goodUShort = 20000;
BigInteger badUShort = 66000;
ushort uShortFromBigInteger;
uShortFromBigInteger = (ushort) goodUShort;
Console.WriteLine(uShortFromBigInteger);
try
{
uShortFromBigInteger = (ushort) badUShort;
Console.WriteLine(uShortFromBigInteger);
}
catch (OverflowException e)
{
Console.WriteLine("Unable to convert {0}:\n {1}",
badUShort, e.Message);
}
}
}
The code above generates the following result.