how to add this without getting an error and getting the exact sum?
int a = 10000000000000; int b = 10000000000000; int c = a + b; Messagebox.Show(Convert.ToString(c)); 10000000000000 is a higher than int could hold. If you check the max value of int int.MaxValue you get 2147483647. So you should use long there and everything would be ok:
long a = 10000000000000; long b = 10000000000000; long c = a + b; Console.WriteLine(Convert.ToString(c)); Range of int is [-2147483648,2147483647]
Range of long is [-9223372036854775808,9223372036854775807]
A signed int can only represent numbers between -2,147,483,648 and 2,147,483,647(https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types).
You can represent larger range of numbers by using long instead of int.
longinstead ofint. And if that's not enough, there'sSystem.Numerics.BigIntegerBigInteger, you can take a look at C# - Data Types (TutorialPoints) and Integral numeric types (C# reference) and Floating-point numeric types (C# reference).