tailieunhanh - Effective C#50 Specific Ways to Improve Your C# Second Edition phần 8

Thay vào đó, thích thêm tuần tự với các loại của bạn khi thực tế. Nó sẽ được thiết thực cho tất cả các loại không đại diện cho giao diện người dùng vật dụng, cửa sổ, hoặc các hình thức. Làm việc thêm nhận thức là không có lý do. NET serialization hỗ trợ rất đơn giản rằng bạn không có bất kỳ lý do hợp lý không hỗ trợ nó. | This page intentionally left blank From the Library of Wow eBook 5 Dynamic Programming in C There are advantages to both static typing and dynamic typing. Dynamic typing can enable quicker development times and easier interoperability with dissimilar systems. Static typing enables the compiler to find classes of errors. Because the compiler can make those checks runtime checks can be streamlined which results in better performance. C is a statically typed language and will remain one. However for those times when dynamic languages provide more efficient solutions C now contains dynamic features. Those features enable you to switch between static typing and dynamic typing when the needs arise. The wealth of features that you have in static typing means that most of your C code will be statically typed. This chapter shows you the problems suited for dynamic programming and the techniques you will use to solve those problems most efficiently. Item 38 Understand the Pros and Cons of Dynamic C s support for dynamic typing is meant to provide a bridge to other locations. It s not meant to encourage general dynamic language programming but rather to provide a smoother transition between the strong static typing associated with C and those environments that use a dynamic typing model. However that doesn t mean you should restrict your use of dynamic to interoperating with other environments. C types can be coerced into dynamic objects and treated as dynamic objects. Like everything else in this world there s good and bad in treating C objects as dynamic objects. Let s look at one example and go over what happens both good and bad. One of the limitations of C generics is that in order to access methods beyond those defined in you need to specify constraints. Furthermore constraints must be in the form of a base class a set of interfaces or the special constraints for reference type value type and the existence of a public parameterless constructor. You can t .

TỪ KHÓA LIÊN QUAN