C# BigInteger TryParse(String, BigInteger)

Description

BigInteger TryParse(String, BigInteger) Tries to convert the string representation of a number to its BigInteger equivalent, and returns a value that indicates whether the conversion succeeded.

Syntax

BigInteger.TryParse(String, BigInteger) has the following syntax.


public static bool TryParse(
  string value,
  out BigInteger result
)

Parameters

BigInteger.TryParse(String, BigInteger) has the following parameters.

  • value - The string representation of a number.
  • result - When this method returns, contains the BigInteger equivalent to the number that is contained in value, or zero (0) if the conversion fails. The conversion fails if the value parameter is null or is not of the correct format. This parameter is passed uninitialized.

Returns

BigInteger.TryParse(String, BigInteger) method returns true if value was converted successfully; otherwise, false.

Example


/*w w  w. j a  va 2s.co  m*/
using System;
using System.IO;
using System.Numerics;

public class Example
{
   public static void Main()
   {
        BigInteger number1, number2;
        bool succeeded1 = BigInteger.TryParse("-123123123123", out number1);
        bool succeeded2 = BigInteger.TryParse("123123123123", out number2);
    
   }
}




















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex