K
Ken Varn
I want to create a custom collection class that is similar to something like
the System.Windows.Forms.Control.ControlCollection.
I notice that this collection implements IList, ICollection, IEnumrable, and
ICloneable. I have tried to create a similar class, but one thing that I
cannot seem to understand is that the ControlCollection provides overrides
to the interfaces with specific object types rather than the generic object
class. i.e., Add method accepts a Control type and not a generic Object
type as is specified in IList.
When I have tried to do the same, I cannot get the compiler to allow me to
specify a method with a more specific type as an override for the interface.
Can someone explain how to do this?
C# snippet example:
public class MyClass : IList
{
public virtual void Add(Control.Label MyLabel); // How can I implement
IList.Add with a specific type?
}
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
(e-mail address removed)
-----------------------------------
the System.Windows.Forms.Control.ControlCollection.
I notice that this collection implements IList, ICollection, IEnumrable, and
ICloneable. I have tried to create a similar class, but one thing that I
cannot seem to understand is that the ControlCollection provides overrides
to the interfaces with specific object types rather than the generic object
class. i.e., Add method accepts a Control type and not a generic Object
type as is specified in IList.
When I have tried to do the same, I cannot get the compiler to allow me to
specify a method with a more specific type as an override for the interface.
Can someone explain how to do this?
C# snippet example:
public class MyClass : IList
{
public virtual void Add(Control.Label MyLabel); // How can I implement
IList.Add with a specific type?
}
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
(e-mail address removed)
-----------------------------------