zoukankan      html  css  js  c++  java
  • Part 45 to 47 Talking about Enums in C#

    Part 45   C# Tutorial   Why Enums

    Enums are strongly typed constants.

    If a program uses set of integral numbers, consider replacing them with enums. Otherwise the pragram becomes less 

    Readable Maintainable

    Part 46   C# Tutorial   Enums Example

    public enum gender
    {
         male,
         female
    }

    Part 47   C# Tutorial   Enums in c#

    If a program uses set of intergral numbers, consider replacing them with enums,which makes the program more readable and maintainable

    1,Enums are enumerations.

    2,Enums are strongly typed constants(常量). Hence(因此),an explicit(显式) cast is needed to convert from enum type to an integral type and vice versa.Also, an enum of one tpe cannot be implicitly(隐式)  assigned(指定) to an enum of another type even though the underlying value of their members are the same.

    3,the default underlying type of an enum is int.

    4, the defalut value for first element is ZERO and gets incremented(递增) by 1.

    5,It is possible to customize the underlying type and values.

    6,Enums are value types.

    7,Enum keyword(all small letteres) is used to create enumerations, where as Enum class,contains static GetValues() and Get Names() methods which can be used to list Enum underlying type values and Names.

  • 相关阅读:
    关于es6的箭头函数使用与内部this指向
    如何使用node中的buffer
    node里如何查看浏览器信息
    我也来写个小爬虫 ^_^
    长篇小说关键字瞬间过滤
    数组 字符串 常用操作
    怎样防止重复发送 Ajax 请求?
    js运算
    表单重复提交
    只能输入数字
  • 原文地址:https://www.cnblogs.com/gester/p/4227589.html
Copyright © 2011-2022 走看看