Why do we dislike the anonymous types in listing 4?
我们为何不喜欢清单4中的匿名类型?
Anonymous types should be avoided for a number of reasons.
基于以下几个原因,应该避免使用匿名类型。
Properties of anonymous types cannot contain pointer types.
匿名型别的属性不能包含指标型别。
Anonymous types must be declared with an object initializer.
匿名类型必须用对象初始值设定项加以声明。
These issues can be remedied by converting anonymous types to named types.
可以通过将匿名类型转换为命名类型来解决这些问题。
Structural Subtyping (duck typing) using type inference and anonymous types.
使用类型引用和匿名类型的结构子类型转化(动态类型)。
So if you have the freedom to modify the schemas, it is best to avoid anonymous types.
因此,如果您可以自由修改架构,最好避免匿名类型。
Structures of anonymous types are more difficult to discuss than structures of named types.
讨论匿名类型结构比讨论命名类型结构更加困难。
VB allows both mutable and immutable anonymous types, with subtly different rules for each.
而VB却同时支持可变和不可变的匿名类型,对于这两种匿名类型,实现和使用的规则也略有不同。
The Submap refinement is not available when working with local elements or anonymous types.
submap细化不可用于处理局部元素或匿名类型。
JAXB is robust enough to allow you to name anonymous types as you need to via the binding file.
JAXB非常稳健,可允许您通过绑定文件来命名需要命名的匿名类型。
In the case of local elements or anonymous types, reusable mappings are not an option at this time.
对于局部元素或匿名类型,目前不能使用可重用映射。
As of WebSphere Process Server 6.0.1, anonymous types use the parent element name appended by _._type.
对于WebSphereProcessServer6.0.1,匿名类型将使用后面追加了_ . _type的父元素名。
The reason VB and C# can use different implementations is that anonymous types are a compiler feature.
VB和C#之所以能不同的实现方式是因为匿名类型是一个编译器特性。
This article codifies issues that may arise from using anonymous types in hopes that readers will avoid them.
本文将总结使用匿名类型可能会引起的问题,希望读者能够避免它们。
Note that in this particular example the final output is not a group, but a flat sequence of anonymous types.
请注意,在此特定示例中,最终的输出不是组,而是匿名类型的平面序列。
Query expressions make frequent use of anonymous types, which can only be initialized with an object initializer.
查询表达式经常使用匿名类型,而这些类型只能使用对象初始值设定项进行初始化。
The CLR itself doesn't have any notion of anonymous types and sees them as normal classes with automatically generated names.
CLR自己对匿名类型没有什么概念,只是把它们看作有着自动产生名字的普通类。
Anonymous types allow you to define a class, then declare and initialize an object of that class, without giving the class a name.
匿名类型允许您定义一个类,然后在不给出类名称的情况下声明并初始化该类的对象。
Implicitly-typed arrays are usually used in query expressions together with anonymous types and object and collection initializers.
隐含型别阵列通常是在查询运算式中与匿名型别及物件和集合初始设定式一起使用。
Type Inference - the var keyword, which is necessary when using anonymous types, can also reduce redundancy in your other variable declarations.
类型推断—使用匿名类型时,关键字var必不可少。它还能减少你其他变量声明中的冗余。
To pass an anonymous type, or a collection that contains anonymous types, outside a method boundary, you must first cast the type to object.
若要在方法界限外传递匿名型别或包含匿名型别的集合,您必须先将型别转型为物件。
For anonymous types, the binder implementation should make sure that the returned SOAPElement always has the QName matching the defined schema type.
对于匿名类型,绑定实现应该确保返回的SOAPElement的QName 与定义的脚本类型匹配。
In order to support data structures like hash tables and query operations like grouping, anonymous types created by LINQ must provide stable hash codes.
为了支持类似哈希表的数据结构和像分组这样的查询操作,由LINQ创建的匿名类型必须提供稳定的哈希码。
But in our opinion, anonymous types aren't as readable as named types; a deeply nested XML structure is almost always more difficult to understand readily.
但我们认为,匿名类型没有命名类型那样的可读性;深层嵌套的XML结构通常难以理解。
The qnameScope property affects how the custom binder interacts with the run time system because of differences between the named types and the anonymous types.
由于命名类型和匿名类型的不同,qnamescope属性将影响到定制绑定如何与运行时系统交互。
Query expressions make frequent use of anonymous types, which can only be initialized by using an object initializer, as shown in the following declaration.
查询运算式经常使用匿名型别,此型别只能使用物件初始化设定式初始化,如下列宣告所示。
Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to first explicitly define a type.
匿名型别提供便利的方式将唯读属性集封装至单一物件,而不用先明确定义型别。
Anonymous types are somewhat limited at the moment because they cannot be named, but you can use late binding to work with them even outside of the context in which they were declared.
现在匿名类型某种程度上是受限的,因为它们不能被命名,但是将来你可以用绑定来应用它们,甚至在它们被声明的上下文(Context)外面。
Structural types specify only the structure a subtype must support; you could think of them as "anonymous" types.
结构类型仅制定了子类型必须支持的结构;你可以把它们看作是“匿名”类型。
应用推荐