Initial Value of an Enum

前端 未结 10 564
陌清茗
陌清茗 2020-12-08 01:51

I have a class with a property which is an enum

The enum is

/// 
/// All available delivery actions
/// 
public enum E         


        
10条回答
  •  眼角桃花
    2020-12-08 02:20

    By default only reference types are nullable types. If you want a variable to allow nulls you have to define it as nullable using the "?" character (for this you need C# 2.0 or up).

    enum MyEnum
    {
        ValueOne,
        ValueTwo
    }
    

    and in your class

    MyEnum? myvariable = null;
    

提交回复
热议问题