Last active
March 28, 2016 22:17
-
-
Save cerkit/15e6ef7f4f877795b633 to your computer and use it in GitHub Desktop.
I have a dilemma. Should I use line 4, 8, 12, or 16?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dilemma, should I use this code: | |
// NOTE: existingJobDetail.Id is defined as a regular (non-nullable) int. | |
int? parentJobDetailId = existingJobDetail != null ? existingJobDetail.Id as int? : null; | |
// Or this code: | |
int? parentJobDetailId = existingJobDetail != null ? (int?)existingJobDetail.Id : null; | |
// Or (less likely): | |
int? parentJobDetailId = existingJobDetail != null ? existingJobDetail.Id as Nullable<int>: null; | |
// Or: | |
int? parentJobDetailId = existingJobDetail != null ? (Nullable<int>)existingJobDetail.Id : null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you not just create a new nullable variable do a SetValue? I don't have a C# compiler handy + have done very little C# for quite a while.