码迷,mamicode.com
首页 > 其他好文 > 详细

C#匿名类型 - Anonymous Types

时间:2014-07-18 21:08:09      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   strong   

C#匿名类型 - Anonymous Types

  Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to explicitly define a type first. The type name is generated by the compiler and is not available at the source code level. The type of each property is inferred by the compiler.

  匿名类型属性为只读,被编译器生成,每个属性被编译器推断生成。

  bubuko.com,布布扣

  匿名类型最常用场景为,当一个类数据过大,而我们只想抽取其中几个属性来使用时。例如:

  bubuko.com,布布扣

  也可以生成匿名类型数组:

  bubuko.com,布布扣

参考:http://msdn.microsoft.com/zh-cn/library/bb397696.aspx

C#匿名类型 - Anonymous Types,布布扣,bubuko.com

C#匿名类型 - Anonymous Types

标签:style   blog   http   color   使用   strong   

原文地址:http://www.cnblogs.com/tekkaman/p/3850219.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!