View Single Post
  #3 (permalink)  
Old 11-03-2007, 11:59 PM
jmcilhinney's Avatar
jmcilhinney jmcilhinney is offline
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,118
Reputation: 541
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

If you're using .NET 2.0 as your profile says then you shouldn't be inheriting CollectionBase at all. You should be inheriting System.Collections.ObjectModel.Collection(Of T), where T is the type of the items the collection will store. For instance, to create a strongly-typed collection of Thing objects you declare the class like this:
Code:
Public Class ThingCollection
    Inherits System.Collections.ObjectModel.Collection(Of Thing)
End Class
That's all you need. Unlike the CollectionBase class there's no need to declare any members at all if you only want standard functionality because it's ALL inherited from Collection(Of Thing). Only if you need to do extra processing when an item is added or the like do you need to add any code at all.
Reply With Quote