What is New in the .NET Framework 4-Tips No-01

Posted By  RRaveen On 10 May 2010 21:05:38
emailbookmarkadd commentsprint
No of Views:495
Bookmarked:0 times
Votes:0 times

Introduction

The purpose this structure is an arbitrary-precision integer data type that supports all the standard integer operations, including bit manipulation. It can be used from any .NET Framework language. In addition, some of the new .NET Framework languages (such as F# and IronPython) have built-in support for this structure.

How to use

Declaration

BigInteger objbigInt = new BigInteger(179032.6541);

Another way of declaration,

create a long variable and then assign directly that variable to bigInteger object like followings.

long longValue = 6315489358112;      
BigInteger assignedFromLong = longValue;

And this is also support all type of basic casting and convert as hexa.

Complete Sample

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string positiveNoString = "91389681247993671255432112000000";
            string negativeNoString = "-90315837410896312071002088037140000";
            BigInteger posBigInt = 0;
            BigInteger negBigInt = 0;

            try
            {
                posBigInt = BigInteger.Parse(positiveNoString);
                Console.WriteLine(posBigInt);
            }
            catch (FormatException)
            {
                Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.",
                                  positiveNoString);
            }

            if (BigInteger.TryParse(negativeNoString, out negBigInt))
                Console.WriteLine(negBigInt);
            else
                Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.",
                                   negativeNoString);
  
       
        }
    }
}

What are the methods and propertie has this structure.here is snap shot of the System.Numerics.BigInteger

 

Image Loading

 

Here is more information .enjoy the new .NET Framework 4.0 features.

Sign Up to vote for this article
Other popular Tips/Tricks
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top