打赏

程序中魔法数字问题

public class Program
{
    static void Main(string[] args)
    {
        int state1 = (int)EnumApplyVehicleState.Approving;
        int state2 = ApplyVehicleState.Approving;
    }
}

public enum EnumApplyVehicleState
{
    Approving=1,
    Dispatching=2,
    Returning=3
}

public class ApplyVehicleState
{
    public static int Approving { get; } = 1;
    public static int Dispatching { get; } = 2;
    public static int Returning { get; } = 3;
}

 

posted @ 2022-02-17 15:14  刘奇云  阅读(81)  评论(0)    收藏  举报