Mike,
Can you provide code for what you are trying?
Remember that if you define the method in the Interface with "ICollection"
the implementing method also needs to be ICollection! However you can use
"Explicit Interface Implementation" where you can "overload" the return type
of the implementing method.
Something like:
Public Interface ITreeNode
ReadOnly Property Children() As ICollection
End Interface
Public Class TreeNode
Implements ITreeNode
Private ReadOnly m_children As TreeNodeCollection
Private ReadOnly Property ITreeNode_Children() As
System.Collections.ICollection Implements ITreeNode.Children
Get
Return Me.Children
End Get
End Property
Private ReadOnly Property Children() As TreeNodeCollection
Get
Return m_children
End Get
End Property
End Class
The TreeNode.Children is the type safe collection that matches TreeNode,
while ITreeNode_Children is the version of the method required by the
Interface.
Hope this helps
Jay
Mike Caputo said:
So I'm trying to make a generic TreeNode interface in order to simplify
converting between a Windows Forms TreeView and an ASP.NET TreeView. I
define one of the properties on the interface (Children) as an ICollection,
but when I then try to implement the property as a Collection (or ArrayList,
or any other class that implements ICollection), it doesn't work. The same
is true if I define the interface property as CollectionBase. Am I doing
something wrong, or is this just a VB limitation, or something else? I just
don't see the point of creating an interface if it can't be defined using
base classes or other interfaces... that really limits the usefulness of
interfaces as far as I can tell. Any suggestions would be greatly
appreciate. Thanks.