Visual Basic .NET The Complete Reference phần 4

khi dữ liệu được rõ ràng gửi đến các phương pháp thông qua danh sách tham số chính thức của nó. Sẽ có thêm thông tin về dữ liệu phương pháp sau trong chương pháp thực hiện công việc của họ với dữ liệu địa phương hoặc dữ liệu lớp. | Method Data Global vs. Local or values and take action accordingly. It can perform such checks in a number of ways which includes specifying the type required a built-in strong typing filter. The level of method coupling varies in the previous four key options for providing data to the method. The highest level of coupling between methods results from the class level or global variables while the lowest level of coupling is achieved when data is explicitly sent to the method via its formal parameter list. There will be more information on method data later in this chapter. Method Data Global vs. Local Methods perform their work with local data or class data. When you need to modify variables for other methods in the class or for operations that interest the entire class then use class variables. If no other method requires access to the variable or needs to use it then declare it local to the method. In my opinion you should not declare class variables if you don t need to because the narrower the scope of access on a variable the more secure it is and the less coupled your method will be to other methods in the class. There is another school of thought however that says passing arguments to methods requires more resources from the run-time environment. I don t believe this is a valid argument no pun intended in the world of managed code and execution because the common language runtime manages the call stacks with a very high degree of sophistication. Providing too many global variables eventually leads to problems. Another criterion for declaring class variables or constants is when the values need to remain intact after the method has performed its work. Local variables are created and initialized either to the default values of their types or values you provide when the method is invoked or called. The data and references are subsequently destroyed when method execution ends. As mentioned earlier you can use a static variable in a method if you require value .

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
2    64    2    28-04-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.