Declaring and Using Delegates

Kê khai và sử dụng đại biểu Một đại biểu là một con trỏ đến một phương pháp. Một đại biểu trông và hoạt động giống như một phương pháp thông thường khi nó được gọi là. Tuy nhiên, khi bạn gọi một đại biểu, thời gian chạy thực sự thực hiện các phương pháp đại biểu đề cập đến. | Declaring and Using Delegates A delegate is a pointer to a method. A delegate looks and behaves much like an ordinary method when it is called. However when you call a delegate the runtime actually executes the method the delegate refers to. You can dynamically change the method that a delegate references so code that calls a delegate might actually run a different method each time it executes. The best way to understand delegates is to see them in action so let s work through an example. NOTE If you are familiar with C a delegate is very similar to a function pointer. However unlike function pointers delegates are type-safe you can only make a delegate refer to a method that matches the signature of the delegate and you cannot call a delegate that does not refer to a valid .

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
114    405    1    01-06-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.