C# BigInteger Explicit(BigInteger to Byte)

Description

BigInteger Explicit(BigInteger to Byte) Defines an explicit conversion of a BigInteger object to an unsigned byte value.

Syntax

BigInteger.Explicit(BigInteger to Byte) has the following syntax.


public static explicit operator byte (
  BigInteger value
)

Parameters

BigInteger.Explicit(BigInteger to Byte) has the following parameters.

  • value - The value to convert to a Byte.

Returns

BigInteger.Explicit(BigInteger to Byte) method returns An object that contains the value of the value parameter.

Example


//from   w  w w  .j ava2s  .c  o m

using System;
using System.IO;
using System.Numerics;

public class Example
{
   public static void Main()
   {
        BigInteger goodByte = BigInteger.One;
        BigInteger badByte = 256;
        
        byte byteFromBigInteger;   
        
        byteFromBigInteger = (byte) goodByte;
        Console.WriteLine(byteFromBigInteger);
        
        try
        {
           byteFromBigInteger = (byte) badByte;
           Console.WriteLine(byteFromBigInteger);
        }
        catch (OverflowException e)
        {
           Console.WriteLine("Unable to convert {0}:\n   {1}", 
                             badByte, e.Message);
        }
    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex