int value=0;
if (value == 0)
{
value = null;
}
How can I set value
to null
above?
Any help will be appreciated.
.netc++intnullnullable
int value=0;
if (value == 0)
{
value = null;
}
How can I set value
to null
above?
Any help will be appreciated.
Best Answer
In .Net, you cannot assign a
null
value to anint
or any other struct. Instead, use aNullable<int>
, orint?
for short:Further Reading