KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a number of methods doing next: var result = command.ExecuteScalar() as Int32?; if(result.HasValue) { return result.Value; } else { throw new Exception(); // just an example, in my code I throw my own exception } I wish I could use operator ?? like this: return command.ExecuteScalar() as Int32? ?? throw new Exception(); but it generates a compilation error. Is it possible to rewrite my code or there is only one way to do that?
Tags (comma-separated)
Save Edits
Cancel