What is the equivalent of bigint in C#?

Asad picture Asad · Jan 21, 2010 · Viewed 225.6k times · Source

What am I supposed to use when handling a value in C#, which is bigint for an SQL Server database?

Answer

Patrick Karcher picture Patrick Karcher · Jan 21, 2010

That corresponds to the long (or Int64), a 64-bit integer.

Although if the number from the database happens to be small enough, and you accidentally use an Int32, etc., you'll be fine. But the Int64 will definitely hold it.

And the error you get if you use something smaller and the full size is needed? A stack overflow! Yay!