When you declare an enum, by default each enumerated value is represented internally with an int. (System.Int32 - 4 bytes). You can convert between values of the underlying type and enum values using an explicit cast. Because an enum is represented by an int by default, you can convert between integers and enum values.

 Mood m = (Mood);
Console.WriteLine(m); // Petulant m = Mood.Crabby;
int i = (int)m;
Console.WriteLine(i); //

原文地址:#457 Converting Between enums and their Underlying Type

【转载】#457 Converting Between enums and their Underlying Type的更多相关文章

  1. 【转载】#458 Errors While Converting Between enum and Underlying Type

    You can convert to an enum value from its underlying type by casting the underlying type (e.g. int) ...

  2. (转载)Android xml资源文件中@、@android:type、@*、?、@+引用写法含义以及区别

    原帖地址:http://blog.csdn.net/zfrong/article/details/7332545 Android xml资源文件中@.@android:type.@*.?.@+引用写法 ...

  3. 关于C#你应该知道的2000件事

    原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...

  4. [Chromium文档转载,第002章]Mojo C++ Bindings API

    Mojo C++ Bindings API This document is a subset of the Mojo documentation. Contents Overview Getting ...

  5. 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 integ ...

  6. Effective Java 34 Emulate extensible enums with interfaces

    Advantage Disadvantage Enum types Clarity Safety Ease of maintenance. None extensibility Typesafe en ...

  7. FB01与F-02的区别(转载)

    FB01与F-02的区别(转载) FB01 : a) ''Post Document'' b) No doc type as SA automatically comes. c) No automat ...

  8. C#可空类型(转载)

    在程序开发中,有时候需要值类型也为可空类型,比如,在数据库中,我们可以把一个日期Datetime设置为null. 在C# 2.0中就出现了可空类型,允许值类型也可以为空(null),可空类型的实现基于 ...

  9. 【转载】Python: Enum枚举的实现

    转自:http://www.cnblogs.com/codingmylife/archive/2013/05/31/3110656.html   从C系语言过来用Python,好不容易适应了写代码不打 ...

随机推荐

  1. 剑指offer——面试题15.2:判断两个整数m和n的二进制中相差多少位

    #include"iostream" using namespace std; int CountDifferentBit(int m,int n) { ,diff=m^n; wh ...

  2. 《阿里如何实现秒级百万TPS?搜索离线大数据平台大数据平台架构解读》读后感

    在使用淘宝时发现搜索框很神奇,它可以将将我们想要的商品全部查询出来,但是我们并感觉不到数据库查询的过程,速度很快.通过阅读这篇文章让我知道了搜索框背后包含着很多技术,对我以后的学习可能很有借鉴. 平时 ...

  3. URL篇之相对URL

    URL有两种方式:绝对的和相对的. 绝对URL中包含有访问资源所需的全部信息,是访问网络资源必须的. 相对URL是不完整的,要从相对URL中获取访问资源所需的全部信息,就必须相对于另一个被称为其基础( ...

  4. TOJ 4002 Palindrome Generator

    描述 A palindrome is a number that reads the same whether you read it from left to right or from right ...

  5. springMVC静态资源访问

    springMVC默认是访问不到静态资源的,如css,js等,需要在xml里进行配置 保证已经配置好了 web.xml, <!-- Spring MVC servlet --> <s ...

  6. 深入理解JavaScript系列(14):作用域链(Scope Chain)

    前言 在第12章关于变量对象的描述中,我们已经知道一个执行上下文 的数据(变量.函数声明和函数的形参)作为属性存储在变量对象中. 同时我们也知道变量对象在每次进入上下文时创建,并填入初始值,值的更新出 ...

  7. [转]浅谈微信小程序

    本文转自:http://www.cnblogs.com/liziyou/p/6340159.html 微信小程序 1.什么是小程序 小程序是指微信公众号平台小程序,小程序可以在微信内被便捷的获取和转播 ...

  8. 关于meta标签中的http-equiv属性使用介绍

    关于meta标签中的http-equiv属性使用介绍 meta是html语言head区的一个辅助性标签.也许你认为这些代码可有可无.其实如果你能够用好meta标签,会给你带来意想不到的效果,meta标 ...

  9. Implementation: Quick Sort 2014-08-19

    #include <stdio.h> void print(int *a, int start , int end); void quick_sort(int *a, int start, ...

  10. springmvc 全局的异常拦截处理 @ControllerAdvice注解 @ExceptionHandler

    第一步: Dispatcher前端控制器的源码中 默认的 private boolean throwExceptionIfNoHandlerFound = false;说明如果没有找到匹配的执行器,不 ...