What is the equivalent of bigint in C#?

Viewed 277503

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

12 Answers

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!

For most of the cases it is long(int64) in c#

int(64) or long Datatype is equivalent to BigInt.

I managed to convert the (bigint) value returned from the DB using Convert.ToInt64.

ie

var Id = Convert.ToInt64(identityAsTable.Rows[0].Field<object>(0));

if you are using bigint in your database table, you can use Long in C#

Related