stupid question but this statement is worthless
int a; if (a != null)
since an integer var is automatically set to null by the compiler when defined
to check integers always check if a >= 0 correct?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The compiler sets the value of a primitive variable to its ‘default’ value if you don’t assign it. The default value of int is 0. So yeah, the comparison you mention doesn’t really do anything.
If you need a nullable int in your code you should use the ‘nullable’ type ‘int?’.
If your int is nullable, then the comparison you mention might be useful.