TAILIEUCHUNG - Using Delegates

Sử dụng đại biểu trong việc thực hiện sau đây, bạn sẽ tạo ra một đại biểu để đóng gói một phương pháp có hiển thị thời gian trong một hộp văn bản Microsoft Windows. Bạn sẽ đính kèm các đối tượng đại biểu cho một lớp được gọi là Mã CK mà chạy sẽ đoàn mỗi giây. | Using Delegates In the following exercise you will create a delegate to encapsulate a method that displays the time in a Microsoft Windows text box. You will attach the delegate object to a class called Ticker that invokes the delegate every second. In this way you will create a Windows application that acts as a simple digital clock. Finish the digital clock application 1. Start Microsoft Visual Studio 2005. 2. Open the Delegates project located in the Microsoft Press Visual CSharp Step by Step Chapter 16 Delegates folder in your My Documents folder. 3. On the Debug menu click Start Without Debugging. The project builds and runs. A Windows form displays a digital clock. The clock displays the wrong time. 4. Click Start and then click Stop. Nothing happens. The Start and Stop methods have not been implemented yet. Your task is to implement these methods. 5. Close the window to return to the Visual Studio 2005 environment. 6. Open the source file and display it in the Code and Text Editor window. This file contains a class called Ticker that models the inner workings of a clock. It uses a object called ticking to arrange for a pulse to be sent every second. This class catches the pulse by using an event events will be described shortly and then arranges for the display to be updated by invoking a delegate. 7. In the Code and Text Editor window locate the declaration of the Tick delegate. It is located near the top of the file and looks like this public delegate void Tick int hh int mm int ss The Tick delegate can be used to refer to a method that takes three integer parameters but does not return a value. There is a delegate variable called tickers at the end of the class that is based on this type. The Add and Remove methods in this class allow matching methods to add and remove themselves from the tickers delegate variable class Ticker . public void Add Tick newMethod newMethod public void Remove Tick oldMethod .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.