I have a class with a property which is an enum
The enum is
///
/// All available delivery actions
///
public enum E
Enums are value types. Value types cannot be null and are initialized to 0.
Even if your enum does not have a 0, enum variables will be initialized to 0.
public enum SomeEnum
{
A = 1,
B = 2
}
(later)
SomeEnum x = default(SomeEnum);
Console.WriteLine(x);
Outputs - 0
Some answerers are advocating using Nullable to match your initialization expectations. Becareful with this advice since Nullable is still a value type and has different semantics than reference types. For example, it will never generate a null reference exception (it's not a reference).
SomeEnum? x = default(SomeEnum?);
if (x == null)
{
Console.WriteLine("It's null!");
}
if (x > SomeEnum.B)
{
}
else
{
Console.WriteLine("This runs even though you don't expect it to");
}