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,即无论这个值是否被用过都会遵守这个规则

  • 相关阅读:
    PRTG安装
    如何诊断windows性能问题
    windows性能监控
    PAM 認 證 模 組
    RHEL磁盘修复
    RHEL下修改市区
    Recover database using backup controlfile until cancel
    Cancel-Based Recovery
    北京、上海的人口并不多
    swoole中http_server的配置与使用
  • 原文地址:https://www.cnblogs.com/wos1239/p/4359371.html
Copyright © 2011-2022 走看看