Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Converting a nullable object to an integer

5.00/5 (4 votes)
19 Mar 2011CPOL 15.5K  
Here is a slightly shorter version of your first conversion:object someValue = 1;int result = someValue as int? ?? -1;
Here is a slightly shorter version of your first conversion:
C#
object someValue = 1;
int result = someValue as int? ?? -1;

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)