"Effective C # Quick Notes"-dynamic Programming in C #
static types and dynamic types have strengths, and static types allow the compiler to help you find more errors, because the compiler can do most of the checking at compile time. C # is a static type of language, but it adds dynamic types of language features that can be used more efficiently to solve problems.
this series
Effective C # Quick notes (i)-C # language habits
Effective C # Quick notes (ii)-. NET Resource Hosting
Effective C # quick Note (iii)-expressing design using C #
Effective C # Quick Notes (iv)-using frames
"Effective C #" Quick Notes (v)-dynamic Programming in C #
First, Directory
- 38. Understanding the merits and demerits of dynamic types
- 39. Run-time types that use dynamic types to express generic type parameters
- 40. Declare parameters that accept anonymous types as dynamic
- 41. Using DynamicObject or IDynamicMetaObjectProvider to achieve data-driven dynamic types
- 42. How to use an expression API
- 43. Use expressions to convert deferred bindings to pre-bound
- 44. Minimize the use of dynamic types in the public API
38. Understanding the merits and demerits of dynamic types
1. Dynamic typing is the best tool when you need to be aware of specific types of runtime parsing methods.
2. Use static types preferentially, and static types are more efficient than dynamic types.
3. If you can control all the types involved in the program, you can introduce an interface instead of a dynamic type, that is, interface-based programming and have all types that need to support the behavior of that interface implement that interface. The C # type system reduces the errors generated by the code at run time, and the compiler can generate more efficient code.
39. Run-time types that use dynamic types to express generic type parameters
1.convert<t> are more adaptable than cast<t>.
40. Declare parameters that accept anonymous types as dynamic
1. Do not overuse dynamic types, because dynamic calls can increase the overhead of the system, even if it is not very large.
2. Extension methods cannot be based on dynamic object definitions.
41. Using DynamicObject or IDynamicMetaObjectProvider to achieve data-driven dynamic types
1. The simplest way to create a type with dynamic functionality is to inherit System.Dynamic.DynamicObject. If you can inherit dynamicobject directly, then it is simpler to create dynamic classes.
42. How to use an expression API
43. Use expressions to convert deferred bindings to pre-bound
44. Minimize the use of dynamic types in the public API
1. Prefer to use static types in C # and minimize the scope of dynamic types. If you want to use dynamic features all the time, you should choose a dynamic language rather than C #.
2. To use dynamic features in your program, try not to use them in a public interface, which restricts the dynamic type to a single object (or type).
"Bo Master" anti-bone Aberdeen
"Original" http://www.cnblogs.com/liqingwen/p/6816100.html
"GitHub" Https://github.com/liqingwen2015/XMind can download XMind
"Reference" "Effective C #"
[. NET] Effective C # Quick notes-dynamic Programming in C # (first draft)