TAILIEUCHUNG - Professional C# Third Edition phần 3

tên phản ánh khác của những sự mơ hồ thuật ngữ mà bệnh dịch hạch máy tính. Bộ sưu tập thường được sử dụng chính thức để chỉ bất kỳ cấu trúc dữ liệu. Tuy nhiên, nó cũng có ý nghĩa cụ thể của một lớp mà thực hiện IEnumerable ICollection một loại đặc biệt của cấu trúc dữ liệu mà chúng tôi sẽ điều tra sau trong chương này. | Chapter 9 -----Simpo PDF Merge and Split Unregistered Version - http With the exception of the basic all the data structure classes are located in the System. Collections namespace. The name reflects another of those terminology ambiguities that plague computing. Collection is often used informally to denote any data structure. However it also has the more specific meaning of a class that implements lEnumerable or iCollection a particular type of data structure that we will investigate later in this chapter. In this chapter we will always use the term collection to refer to the more specific meaning except where .NET base class names force us to use it in the general sense. Array Lists An array list is very similar to an array except that it has the ability to grow. It is represented by the class . The ArrayList class also has some similarities with the StringBuilder class. Just as a StringBuilder allocates enough space in memory to store a certain number of characters and allows you to manipulate characters within the space the ArrayList allocates enough memory to store a certain number of object references. You can then efficiently manipulate these object references . If you try to add more objects to the ArrayList than permitted then it will automatically increase its capacity by allocating a new area of memory big enough to hold twice as many elements as the current capacity and relocate the objects to this new location. You can instantiate an array list by indicating the initial capacity you want. For this example we will assume we are creating a list of Vectors ArrayList vectors new ArrayList 20 If you don t specify the initial size it defaults to 16 ArrayList vectors new ArrayList capacity of 16 You can then add elements using the Add method new Vector 2 2 2 new Vector 3 5 6 The ArrayList treats all its elements as object references. That means you can store

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