I want to check if my Listentry = null but I don't know how.
Note: ID is a Integer
Here is my Code
if(MeineGaeste[i].ID !=null)
{
i++;
}
else
{
MeinGast.ID = i++;
test = false;
}
As stated, an int cannot be null. If a value is not set to it, then the default value is zero. You can do a check for 0 if that is what you think it is being set to...
Otherwise if you are keen on avoiding nullable integers, you would have to turn it into a string and then perform the check.
String.IsNullOrEmpty(ID.ToString());
Which returns a boolean so you can stick it into an if statement.
An int
cannot be null. On the other hand a nullable int, int?
, can be. That being said the check that you want to do is meaningless.
Changing the type of ID
from int
to int?
, the check you do has a meaning and the compiler wouldn't complain about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With