tags:

views:

18

answers:

1

my class - Class GenericNameValueCollection(Of valueT) inherits from NameObjectCollectionBase, but when I iterate a collection of this class it lets me use any object in the for each loop , I want it to check the type of object and make sure that the object is the same type as the collection, but the NameObjectCollectionBase GetEnumerator function is allowing any object type.I also tried adding Implements IEnumerator(Of valueT) to my class but it is still getting the enumerator from the base class.

How can I restrict the enumerator to my generic type?

thanks.

A: 

Implement IEnumerable instead, as that is what its looking for

hkon
works, but my enuerator is : Public Class ObjectEnumerator Implements System.Collections.Generic.IEnumerator(Of valueT)aand it is forcing me to implement both these in the enumerator:ReadOnly Property Current() As valueT Implements System.Collections.Generic.IEnumerator(Of valueT).Currentand ReadOnly Property Current1() As Object Implements System.Collections.IEnumerator.Current