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.

Part 45 to 47 Talking about Enums in C#的更多相关文章

  1. 47. 数组中出现次数超过一半的数字[Number appears more than half times]

    [题目]:数组中有一个数字出现的次数超过了数组长度的一半,找出这个数字. 例如长度为9的数组{1,2,3,2,2,2,5,4,2}中次数超过了数组长度的一半的数字为2,而长度为8的数组{1,2,3,2 ...

  2. FF D8 FF FE 00 24 47 00转图片

    String[] img = "FF D8 FF FE 00 24 47 00 9D 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 0 ...

  3. python(47):range和xrange的区别和联系

    range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列. 比如: >>> range(5)[0, 1, 2, ...

  4. 第47章 QR-Decoder-OV5640二维码识别—零死角玩转STM32-F429系列

    第47章     QR-Decoder-OV5640二维码识别 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.y ...

  5. java中类的初始化和对象的初始化

    静态的属于全局静态区,这个部分独立存在,不管是成员还是块,都是静态的,大家地位相等,先到先得. 然后是成员初始化,这个部分在类的构造函数前初始化,因为编译器(或者设计者)可能认为构造函数调用了这个成员 ...

  6. C#压缩、解压缩文件(夹)(rar、zip)

    主要是使用Rar.exe压缩解压文件(夹)(*.rar),另外还有使用SevenZipSharp.dll.zLib1.dll.7z.dll压缩解压文件(夹)(*.zip).需要注意的几点如下: 1.注 ...

  7. 最优雅SSM框架:SpringMVC + Spring + MyBatis

    在写代码之前我们先了解一下这三个框架分别是干什么的? 相信大以前也看过不少这些概念,我这就用大白话来讲,如果之前有了解过可以跳过这一大段,直接看代码! SpringMVC:它用于web层,相当于con ...

  8. Spring + Fastweixin 微信开发

    这篇文章转自<http://www.qtdebug.com/spring-weixin/> 微信有两种模式,编辑模式和开发者模式,有些功能是互斥的,不可以同时使用,微信开发需要在开发者模式 ...

  9. MyBatis 查询映射自定义枚举

    背景                  MyBatis查询若想映射枚举类型,则需要从 EnumTypeHandler 或者 EnumOrdinalTypeHandler 中选一个来使用         ...

随机推荐

  1. ThreadPool for Delphi

    http://sourceforge.net/projects/threadpoolpas/ http://hivelocity.dl.sourceforge.net/project/threadpo ...

  2. XHTML标签的嵌套规则--很基础很重要

    XHTML的标签有许多:div.ul.li.dl.dt.dd.h1~h6.p.a.addressa.span. strong……我们在运用这些标签搭建页面结构的时候,是可以将它们无限嵌套的,但是,嵌套 ...

  3. PHP网址

    15个魔术方法的总结: http://blog.csdn.net/bossdarcy/article/details/6210794 PHP代码重构:http://blog.csdn.net/tony ...

  4. 【转】struct和typedef struct

    原文:http://www.cnblogs.com/qyaizs/articles/2039101.html 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用type ...

  5. 试读《基于MVC的JavaScript Web富应用开发》

    前两年做jsp开发时,用了不少JavaScript(JS)和Ajax, 最近的项目一直在使用Flex做前台,虽然也有类似的ActionScript实现JS的功能,但没想到的是,短短几年JS发展如此迅速 ...

  6. 从零开始学android开发-adt-bundle-eclipse下的修改android app名称

    eclipse中,打开项目根目录中的AndoirManifest.xml文件,找到如下内容 <application android:allowBackup="true" a ...

  7. 关于java.lang.IllegalArgumentException: View not attached to window manager 错误的分析

    今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行.一开始猜想会不会是解锁PIN码的时候处理导致了P ...

  8. 通达OA 公共文件柜二次开发添加管理信息(图文)

    公共文件柜当内容较多时,管理起来非常easy乱,特别是当有多个名字相近的目录时.这里通过简单的开发添加了两个管理信息,能够通过添加备注的方式加以区分. watermark/2/text/aHR0cDo ...

  9. 黑客破译android开发代码真就那么简单?

    很多程序员辛辛苦苦开发出的android开发代码,很容易就被黑客翻译了. Google似乎也发现了这个问题,从SDK2.3开始我们可以看到在android-sdk-windows\tools\下面多了 ...

  10. 【JavaScript】n++ VS ++n

    var n = 1; console.log(n++);--------------->表达式的值为 1; n的值为2 console.log(++n);--------------->表 ...