zoukankan      html  css  js  c++  java
  • C#枚举类型

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    namespace ConsoleApplication1

    {    

      class Program    

      {        

        enum SVal        

        {            

          First,   //如果不特别设置,枚举从0开始            

          Second,  //每个后续值为前一个值加1.            

          Third = -5,            

          Fourth        

        }        

        static void Main(string[] args)        

        {                        

          Console.WriteLine("{0}", (int) SVal.Fourth);            

          Console.ReadLine();

              }    

      }

    }

    每个后续值为前一个值加1.所以输出是-4;

    若改为:
        enum SVal        

        {            

          First,   //如果不特别设置,枚举从0开始            

          Second,  //每个后续值为前一个值加1.            

          Third = -1,            

          Fourth        

        }        

    输出结果是0,即无论这个值是否被用过都会遵守这个规则

  • 相关阅读:
    算法第四章上机实践报告
    算法第三章作业
    算法第三章上机实践报告
    算法第二章总结
    关于stl::sort--算法第二章作业
    算法第二章上机实践报告
    算法第一章作业
    1
    2020-2021-1 20209302毕慧敏《Linux内核原理与分析》第十二周作业
    2020-2021-1 20209302毕慧敏《Linux内核原理与分析》第十一周作业
  • 原文地址:https://www.cnblogs.com/wos1239/p/4359371.html
Copyright © 2011-2022 走看看