Effective C#50 Specific Ways to Improve Your C# 2nd phần 8

Có lợi thế để gõ tĩnh và gõ năng động. Năng động, đánh máy có thể cho phép thời gian phát triển nhanh hơn và khả năng tương tác dễ dàng hơn với các hệ thống khác nhau. Tĩnh đánh máy cho phép trình biên dịch để tìm các lớp học của các lỗi. Bởi vì trình biên dịch có thể làm cho những người kiểm tra, | 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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
24    76    1    04-05-2024
373    68    1    04-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.