C#匿名类型 - Anonymous Types

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.

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

  C#匿名类型 - Anonymous Types

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

  C#匿名类型 - Anonymous Types

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

  C#匿名类型 - Anonymous Types

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

上一篇:word默认字体与大小


下一篇:给博客添加Flash时钟