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

  • 相关阅读:
    tcpip详解笔记(1) 概述
    tcpip详解笔记(11) 广播和多播
    tcpip详解笔记(13) tftp
    tcpip详解笔记(15) TCP协议连接过程
    tcpip详解笔记(8) traceroute
    tcpip详解笔记(5) RARP协议
    tcpip详解笔记(6) icmp协议
    tcpip详解笔记(7) ping
    tcpip详解笔记(4) arp协议
    tcpip详解笔记(3) IP网际协议
  • 原文地址:https://www.cnblogs.com/wos1239/p/4359371.html
Copyright © 2011-2022 走看看