Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Sử dụng Indexers trong một ứng dụng Windows Trong bài tập sau đây, bạn sẽ kiểm tra một ứng dụng điện thoại đơn giản và hoàn thành cuốn sách thực hiện. Nhiệm vụ của bạn sẽ được để viết hai indexers trong lớp danh bạ | Using Indexers in a Windows Application In the following exercise you will examine a simple phone book application and complete its implementation. Your task will be to write two indexers in the PhoneBook class one that accepts a Name parameter and returns a PhoneNumber and another that accepts a PhoneNumber parameter and returns a Name. The Name and PhoneNumber structs have already been written. You will also need to call these indexers from the correct places in the program. Familiarize yourself with the application 1. Start Microsoft Visual Studio 2005. 2. Open the Indexers project located in the Microsoft Press Visual CSharp Step by Step Chapter 15 Indexers folder in your My Documents folder. This is a Microsoft Windows Forms application. 3. On the Debug menu click Start Without Debugging. The project builds and runs. A form displays two empty text boxes labeled Name and Phone Number. The form also contains three buttons one to add a name phone number pair to a list of names and phone numbers held by the application one to find a phone number when given a name and one to find a name when given a phone number. These buttons currently do nothing. Your task is to finish the application so that these buttons work. 4. Close the form and return to Visual Studio 2005. 5. Display the Name.cs source file in the Code and Text Editor window. Examine the Name struct. Its purpose is to act as a holder for names. The name is provided as a string to the constructor. The name can be retrieved by using the read-only string property called Text. The Equals and GetHashCode methods are used for comparing Names when searching through an array of Name values you can ignore them for the time being. 6. Display the PhoneNumber.cs source file in the Code and Text Editor window and examine the PhoneNumber struct. It is very similar to the Name struct. 7. Display the PhoneBook.cs source file in the Code and Text Editor window and examine the PhoneBook class. This class contains two .