Item 40: Use Dynamic for Parameters That Receive Anonymous Types(Effective C#)
2011-02-26 10:38
555 查看
You can leverage dynamic to create methods that are intended to be used with anonymous types. It’s a technique to be used sparingly, like strong spices. If you find yourself creating many methods using dynamic invocation that are intended for use with anonymous types, that’s a strong indication that you should create a concrete type to represent that concept. It will be much easier to maintain over time, and you’ll have better support from the compiler and the type system. However, when you need one or two utility methods that use an anonymous type, dynamic invocation is a simple way to create that behavior.
相关文章推荐
- Item 39: Use Dynamic to Leverage the Runtime Type of Generic Type Parameters(Effective C#)
- Effective C# Item 8: Ensure That 0 Is a Valid State for Value Types
- Item 19: Ensure That 0 Is a Valid State for Value Types(Effective C#)
- Item 36: Understand How to Use PLINQ for I/O Bound Operations(Effective C#)
- 使用Retrofit时出现 java.lang.IllegalArgumentException: URL query string "t={type}&p={page}&size={count}" must not have replace block. For dynamic query parameters use @Query.异常原因
- Effective C#之8:Ensure That 0 Is a Valid State for Value Types
- Item 47: Use traits classes for information about types(Effective C++)
- Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)
- Item20 Use std::weak_ptr for std::shared_ptr like pointers that can dangle
- Item 13: Use Proper Initialization for Static Class Members(Effective C#)
- Most JDBC drivers require that the JdbcType must be specified for all nullable parameters.
- Pseudo code for In-class QuestionExample 3: Write pseudo code that performs the following: Ask a use
- Effective C#之Item 49:Prepare for C# 2.0
- Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical
- Effective C# Item 1: Always Use Properties Instead of Accessible Data Members
- JDBC requires that the JdbcType must be specified for all nullable parameters.
- 编译trimesh2遇到问题:The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant names
- heck the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTI
- Item 20: Prefer Immutable Atomic Value Types(Effective C#)
- Item 21: Limit Visibility of Your Types(Effective C#)