C#枚举转换

        [Fact]
        public void Test()
        {
            int? i = 2;
            var t = Enum.Parse(typeof(ReportTypeEnum), i.ToString());//AntiFraud
            var t2 = (ReportTypeEnum)i;//AntiFraud
            var result = string.Empty;
            switch (t2)
            {
                case ReportTypeEnum.AntiFraud:
                    result = t.ToString();//AntiFraud
                    break;
            }
        }

    public enum ReportTypeEnum
    {
        AntiFraud = 2,
        CreditCheck = 11
    }

你可能感兴趣的:(c#,java,开发语言)