TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P28

Professional Special Edition- P28:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | BestMovieOfAllTime index too big Since types such as the ArrayList will throw an ArgumentOutOfRangeException if an index is invalid we declare an exception handler to catch an error and give the user some basic feedback. We should also handle the general exception case since types could throw other unexpected exceptions try BestMovieOfAllTime string movieList 6 catch ArgumentOutOfRangeException rangeException BestMovieOfAllTime index too big catch Exception e do something useful here The ICollection Interface The ArrayList class supports three collection interfaces IList IEnumerable and ICollection. We ve covered the first two now we ll turn our attention to ICollection. The ICollection interface defines methods and properties that allow us to Determine how many items are in a collection using the Count property . Copy the contents of a collection into a specified array at a given offset using the CopyTo method . Determine if the collection is synchronized and therefore thread-safe. Determine the synchronization root object for the collection using the SyncRoot property . The synchronization root object is the object that is locked and unlocked as collection operations are performed on a synchronized collection. The ICollection interface derives from the IEnumerable interface so it inherits the GetEnumerator method. The Property The following code shows how we can use the property to display the number of items in our movieList ArrayList p There are in the list. p For those types in the class library the implementation of the Count property returns a cached field. It doesn t cause the size of a collection to be recalculated so it isn t expensive to call which means that we don t need to worry about caching the Count property in an effort to get efficiency. The Method The method allows the contents of a collection to be inserted into an array at a specified offset. If the .

23    4    0    15-08-2020
24    4    0    15-08-2020
1    7    0    15-08-2020
382    6    0
18    6    0