tailieunhanh - Mastering Microsoft Visual Basic 2010 phần 6

Một số của các biến địa phương có thể được phổ biến trong tất cả các trường hợp của một lớp: Đây là các biến tương ứng với tính chất chia sẻ (tài sản được chia sẻ bởi tất cả các trường hợp của một lớp). Khi bạn tạo một biến mới của các loại khách hàng, các thủ tục mới () của lớp khách hàng được gọi. | Chapter 12 Storing Data in Collections One of the most common operations in programming is storing large sets of data. Traditionally programmers used arrays to store related data. Because arrays can store custom data types they seem to be the answer to many data-storage and data-manipulation issues. Arrays however don t expose all the functionality you might need in your application. To address the issues of data storage outside databases the Framework provides in addition to arrays certain classes known as collections. There are databases of course that can store any type of data and preserve their structure as well but not all applications use databases. Although databases store data permanently collections live in memory and must be persisted to a disk file between sessions. Collections can also be used to store data you read from a database in the target computer s memory. If your application needs to store custom objects such as the ones you designed in Chapter 8 Working with Objects or a few names and contact information you shouldn t have to set up a database. A simple collection like the ones described in this chapter will suffice. In this chapter you ll learn how to do the following Make the most of arrays Store data in specialized collections such as List and Dictionary collections Sort and search collections with custom comparers Advanced Array Topics Arrays are indexed sets of data and this is how we ve used them so far in this book. In this chapter you will learn about additional members that make arrays extremely flexible. The class provides methods for sorting arrays searching for an element and more. In the past programmers spent endless hours writing code to perform the same operations on arrays but the Framework frees them from similar counterproductive tasks. This chapter starts with a brief discussion of the advanced features of the Array class. With so many specialized collections supported by the Framework arrays are no longer .

TỪ KHÓA LIÊN QUAN