object someValue = 1; int result = someValue as int? ?? -1;
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { object someValue = 1; int result = someValue as int? ?? -1; MessageBox.Show(result.ToString()); } } }
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.