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
1.4m articles
1.4m replys
5 comments
57.0k users