đó là khuyến cáo rằng bạn cô lập tất cả các nguồn lực của bạn trong một hội đồng riêng biệt để họ có thể được trao đổi một cách dễ dàng với một nền văn hóa khác nhau mà không ảnh hưởng đến mã của bạn. Hội đồng chia sẻ đưa chúng ta đến khái niệm về đặt tên lắp ráp. | CHAPTER 4 CLASSES AND STRUCTURES 63 End Sub End Class Public Class Drawing Private Shapes As ArrayList Public Sub New Shapes New ArrayList End Sub Public ReadOnly Property Count As Integer Get Return End Get End Property Default Public ReadOnly Property Item ByVal Index As Integer As GeometricShape Get Return CType Shapes Index GeometricShape End Get End Property Public Sub Add ByVal Shape As GeometricShape Shape End Sub End Class Public Class EntryPoint Shared Sub Main Dim Rectangle As Rectangle New Rectangle Dim Circle As Circle New Circle Dim Drawing As Drawing New Drawing Dim i As Integer 0 Rectangle Circle For i 0 To - 1 Step 1 Dim Shape As GeometricShape Drawing i Next End Sub End Class 64 CHAPTER 4 CLASSES AND STRUCTURES As shown you can access the elements of the Drawing object in the Main routine as if they were inside a normal array. Also since this indexer only has a Get accessor it is read-only. Keep in mind that if the collection holds onto references to objects the client code can still change the state of the contained object through that reference. But since the indexer is readonly the client code cannot swap out the object reference at a specific index with a reference to a completely different object. One difference is worth noting between a real array and the indexer. You cannot pass the results of calling an indexer on an object as a ByRef parameter to a method as you can do with a real array. This is similar to the same restriction placed on properties. Partial Classes Partial classes are a new addition to VB. So far you ve seen how to define classes in one single file. Until now it was impossible to split the definition of a class across multiple files. At first such a convenience may not seem worthwhile. After all if a class has become so large that the file is hard to manage that may be an indication of poor design. But arguably the