C# BigInteger Explicit(BigInteger to SByte)

Description

BigInteger Explicit(BigInteger to SByte) Defines an explicit conversion of a BigInteger object to a signed 8-bit value.

Syntax

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


public static explicit operator sbyte (
  BigInteger value
)

Parameters

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

  • value - The value to convert to a signed 8-bit value.

Returns

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

Example


/*from  w w w.  ja  va2  s  .  c om*/
using System;
using System.IO;
using System.Numerics;

public class Example
{
   public static void Main()
   {
        BigInteger goodSByte = BigInteger.MinusOne;
        BigInteger badSByte = -130;
        
        sbyte sByteFromBigInteger;
        
        sByteFromBigInteger = (sbyte) goodSByte;
        Console.WriteLine(sByteFromBigInteger);
        
        try
        {
           sByteFromBigInteger = (sbyte) badSByte;
           Console.WriteLine(sByteFromBigInteger);
        }
        catch (OverflowException e)
        {
           Console.WriteLine("Unable to convert {0}:\n   {1}", 
                             badSByte, e.Message);
        }
    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex