[. NET] Effective C # Quick notes-dynamic Programming in C # (first draft)

Source: Internet
Author: User

"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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.