-2

I am a C# beginner and I am working on a calculator in Windows Forms.

I've encountered a problem in which I get one of those debug blurbs after 10 or more digits are inputed into the interface. It says something about a system overflow exception, but I don't really understand.

Can someone please tell me a simple way to make an Int64 variable?

CSᵠ
  • 10,049
  • 9
  • 41
  • 64
user3587709
  • 89
  • 1
  • 6

2 Answers2

3

You can use BigInteger from Numerics library.

you need to add the System.Numerics library. Folow the below steps to add it.

Step 1: Right Click on your Project References
Step 2: Click on AddReference...
Step 3: from the FrameWork category you need to select the System.Numerics

From the Code you can use the same library :

Try This:

using System.Numerics;
BigInteger value = new BigInteger(99999999999999999999999999);
Sudhakar Tillapudi
  • 25,935
  • 5
  • 37
  • 67
0

Try to use BigInteger datatype instead of int datatype, this should be able to hold a very large number.

hkwarrior
  • 35
  • 7
  • 3
    ..and what namespace does the `bigint` type reside in? ... Certainly not `System`... – Simon Whitehead Apr 30 '14 at 04:09
  • 1
    `System.Numerics.BigInteger`-can be used in .NET 4.0 or after [link](http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx) – hkwarrior Apr 30 '14 at 04:18
  • 2
    The reason I called your mistake out was because the OP says "I am a C# beginner". Saying use `bigint` is likely to confuse them.. given that `bigint` isn't actually a type in C#.. rather `BigInteger` is. Small mistake.. but important for the OP. – Simon Whitehead Apr 30 '14 at 04:21