The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
As of .NET 2.0, we have a built-in way
] of converting a
object to an object of type
with a default::
int b = a.GetValueOrDefault(-1);
Your example would then be:
object someValue = null; convertedInteger = ((int?)someValue).GetValueOrDefault(-1);