Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Attributes and XML Comments Cửa sổ Properties và IntelliSense làm một công việc đáng chú ý tìm ra cách của bạn đối tượng và tính chất công việc của họ. Ví dụ, giả sử chương trình của bạn sử dụng đoạn mã sau để xác định JobTypes liệt kê giá trị và chương trình con AssignJob: Công Enum JobTypes Thiết kế Tài liệu phát triển Kiểm tra Debugging End Enum Private Sub AssignJob (ByVal job_type Như JobTypes) . End Sub. | Attributes and XML Comments The Properties window and IntelliSense do a remarkable job of figuring out how your objects and their properties work. For example suppose your program uses the following code to define the JobTypes enumerated values and the AssignJob subroutine Public Enum JobTypes Design Documentation Development Testing Debugging End Enum Private Sub AssignJob ByVal job_type As JobTypes . End Sub If you type AssignJob in the code window IntelliSense automatically displays all of the information shown in Figure 12-1. It shows the AssignJob subroutine s signature below the cursor it displays the list of possible JobTypes values that you could use for the subroutine s first parameter and it even displays the numeric value of the currently selected JobTypes value. Figure 12-1 IntelliSense automatically displays a subroutine s signature and lists possible JobTypes values. Part II Meta-Development Similarly the Properties window automatically discovers the types of the properties provided by a component and supplies appropriate editors in many cases. For example it automatically provides dropdowns for selecting colors or enumerated values dialogs for selecting files or colors and a combination of sub-properties and a dialog for selecting fonts. Visual Studio provides all of this support automatically. Although all of these tools are extremely useful Visual Studio cannot deduce the intent of your code. IntelliSense can list the signature of the Assignjobs subroutine but it cannot guess the routine s purpose. It can display a list of the possible values that you might use for the routine s parameter but it doesn t know what the parameter is for. By using attributes and XML comments you can give additional information that IntelliSense and editors such as the Properties window can use to provide extra support for developers. In most cases adding this support takes only a few seconds but giving developers a better understanding of what the code is supposed to .