private enum E_Week
{
Mon = 0,
Tue,
. . .
}
What does the following code mean?
E_Week? week= null;
Is it equal to the following code? What is the function of the ‘?’ sign here?
E_Week week= null;
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.
Your code is using what’s called a nullable type. An enum, much like an int or a DateTime, is what is known as a “value type”, which is required to always have some value. Nullable types allow you to treat value types as if they do allow null values.
For example, this code is invalid and won’t compile because enums cannot be null:
But this code is valid:
And it’s exactly the same as this: