int value=0;
if (value == 0)
{
value = null;
}
How can I set value
to null
above?
Any help will be appreciated.
See Question&Answers more detail:osint value=0;
if (value == 0)
{
value = null;
}
How can I set value
to null
above?
Any help will be appreciated.
See Question&Answers more detail:osIn .Net, you cannot assign a null
value to an int
or any other struct. Instead, use a Nullable<int>
, or int?
for short:
int? value = 0;
if (value == 0)
{
value = null;
}
Further Reading