You're probably going over the maximum value of an integer. Consider the following two code samples.
static void Main(string[] args)
{
int max = int.MaxValue;
max++;
Console.WriteLine(max);
Console.Read();
} Sub Main()
Dim max As Integer = Integer.MaxValue
max += 1
Console.WriteLine(max)
Console.Read()
End Sub
Aside from language, the two code pieces are identical. The VB version will throw an overflow exception. The C# version executes without a problem. Why?
The answer is that the C# executeswith a hidden problem. If you exceed the maximum value of an integer in C#, it wraps back around to the minimum value!
You say your number is too big for a long, but that your integer version gives you the correct result. Personally, I would revisit that assumption.