Click here to Skip to main content
14,331,316 members

Converting a nullable object to an integer

Rate this:
5.00 (4 votes)
Please Sign up or sign in to vote.
5.00 (4 votes)
19 Mar 2011CPOL
Here is a slightly shorter version of your first conversion:object someValue = 1;int result = someValue as int? ?? -1;



Compare Revision Minor Date Status Editor
3 - publicly available No 19-Mar-11 10:42 Available AspDotNetDev
2 No 19-Mar-11 10:35 Composing
1 No 18-Mar-11 7:49 Composing


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


About the Author

Web Developer
United States United States

  • Managing Your JavaScript Library in ASP.NET (if you work with and you don't read that, you are dead to me).
  • Graduated summa cum laude with a BS in Computer Science.
  • Wrote some articles and some tips.
  • DDR ("New high score? What does that mean? Did I break it?"), ping pong, and volleyball enthusiast.
  • Software I have donated to (you should too):

Tagged as


4 bookmarked