SqlTypes.SqlInt16 is an interesting type. It looks like a short? but it is not, it is actually a struct. It has a bunch of operator overloads that makes it behave like a number. Do note how this version works just fine:
Int64 value = (Int64)(short.MaxValue + 1); // okay
Which uses the "normal" addition operator, it can never overflow since the CLR doesn't actually have a addition operator that works for short. The nearest type it supports is Int32, that doesn't overflow here.
But SqlInt16 was written to catch this mistake, it has an operator+()
overload, it was explicitly written to generate this exception. In other words, it does implement the semantics of a 16-bit addition and yells when the result doesn't fit back into a dbase table column of a 16-bit integral type. Regardless whether you use the checked or unchecked keywords in C#. Which is a Good Thing, you really want to know about that when you work with a dbase.
You need to invoke another method of SqlInt16, a conversion operator. The one that converts SqlInt16 to a native integral type. The tongue-in-cheek variety looks like this:
Int64 value = (Int64)((short)System.Data.SqlTypes.SqlInt16.MaxValue + 1);
But of course it makes more sense to cast to Int64 directly, SqlInt16 has a conversion operator for that one too:
Int64 value = (Int64)System.Data.SqlTypes.SqlInt16.MaxValue + 1;
Do beware the iffy semantics of code like this. You can't cast a dbase column. My first snippet makes more sense.