C# ValueTypes

1、哪些类型是ValueType?

The value types consist of two main categories:

Structs fall into these categories:

2、内置C#值类型实际是C#内置类的alias。例如:

  

3、The C# type keywords and their aliases are interchangeable.

  

4、以下2种初始化的是,一个会调用构造函数初始化,一个不会。

  int myInt;

  myInt = new int(); // Invoke default constructor for int type.

5、Data types are separated into value types and reference types. Value types are either stack-allocated or allocated inline in a structure. Reference types are heap-allocated. Both reference and value types are derived from the ultimate base class Object. In cases where it is necessary for a value type to behave like an object, a wrapper that makes the value type look like a reference object is allocated on the heap, and the value type's value is copied into it. The wrapper is marked so the system knows that it contains a value type. This process is known as boxing, and the reverse process is known as unboxing. Boxing and unboxing allow any type to be treated as an object.

  Although ValueType is the implicit base class for value types, you cannot create a class that inherits from ValueType directly. Instead, individual compilers provide a language keyword or construct (such as struct in C# and Structure…End Structure in Visual Basic) to support the creation of value types.

参考:

1、http://msdn.microsoft.com/zh-cn/library/ya5y69ds.aspx

2、http://msdn.microsoft.com/zh-cn/library/s1ax56ch.aspx

3、http://msdn.microsoft.com/zh-cn/library/system.valuetype(v=vs.110).aspx

最新文章

  1. C# http请求数据
  2. tornado简单的验证码
  3. 【转】VS调试技巧
  4. YesFinder - 网页文件管理系统 V2.0
  5. 杭电1874畅通project绪
  6. 5次Shift会触发粘滞键的妙用(转)
  7. ****ural 1141. RSA Attack(RSA加密,扩展欧几里得算法)
  8. ionic项目上划刷新和下拉刷新
  9. asp.net C# 实现阿里大鱼和云片网短信接口类
  10. MySQL 多实例的安装
  11. 实时监听input输入内容的N种方法
  12. Vue route部分简单高级用法
  13. python数据类型分类
  14. Pandas分组统计函数:groupby、pivot_table及crosstab
  15. ANDROID init进程
  16. localStorage 和 sessionStorage
  17. eos源码分析和应用(一)调试环境搭建
  18. tomcat集群及session共享
  19. MySQL 20个经典面试题
  20. JS的事件冒泡和事件捕获

热门文章

  1. Sprint第一个冲刺(第五天)
  2. Ant入门使用说明
  3. MySQL 8 连接时出现 1251 和 2059 错误
  4. bzoj 1185 [HNOI2007]最小矩形覆盖——旋转卡壳
  5. MySQL主从报错解决:Failed to initialize the master info structure
  6. Unit07: MyBatis框架简介 、 MyBatis基本应用
  7. C++直接初始化和复制初始化2
  8. [模板]LCA的倍增求法解析
  9. java代码---------比较随机数的大小---我搞不懂啊
  10. 网络网关TCP/IP