int value=0; if (value == 0) { value = null; }
How can I set value to null above?
value
null
Any help will be appreciated.
In .Net, you cannot assign a null value to an int or any other struct. Instead, use a Nullable<int>, or int? for short:
int
Nullable<int>
int?
int? value = 0; if (value == 0) { value = null; }
Further Reading
2.1m questions
2.1m answers
60 comments
57.0k users