TAILIEUCHUNG - Define a Class in Visual Basic .NET

9,1 Xác định một Class trong Visual Basic NET Trước khi viết mã., Bạn nên mất một chút thời gian để quyết định loại dữ liệu những gì cần phải có hành động và những gì một nhà phát triển (cho dù đó là bạn hay đồng đội một) sẽ muốn thực hiện trên dữ liệu đó | Define a Class in Visual Basic .NET Before writing code you should take a moment to decide what data the class needs to contain and what actions a developer whether it is you or a teammate would want to perform on that data. For the moment we ll keep it fairly simple by limiting the class to properties representing the columns in the Customers table and to methods that insert delete and update data. Technique Visual Basic .NET has a specific kind of code file that you can use to describe the public members of a class an interface. An interface simply lists all the public variables methods and properties that any class implementing that interface must expose. Interfaces are an enormously powerful and flexible feature of object-oriented programs and this chapter just scratches the surface. Because of the fact that an interface has no code you can focus on the design of your application without the clutter of hundreds of lines of source code. Steps 1. First create a new Windows Application project and name it CustomerClasses. 2. To create a new interface add a new class to your project by right-clicking on the Solution Explorer window and selecting Add Class. Name the new file . 3. Change the class block declaration so that it reads interface instead of class and name the class ICustomer. You should have a code file like that shown in Listing . Listing An Empty Interface Public Interface ICustomer End Interface Add Properties to the Interface The first items you need to add to your interface are properties to represent the columns in the Customers table. 1. Using the Server Explorer drill down to the Customers table in the Northwind database so that you have an easy reference to the Customers table. 2. To make your code more readable add a Region End Region block with the name Properties so that you can expand and collapse your property declarations as needed. 3. For each column in the table add a property .

Đã 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.