Can't override base virtual method

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

Greetings!
I'm trying to implement own collection BaseCollection
(inherited from NameObjectCollectionBase class), but my
attempt to override NameObjectCollectionBase virtual method
public virtual new System.Collections.IEnumerator
GetEnumerator ( )
fails with compiller error:
"'bla.bla.bla.BaseCollection.GetEnumerator()' : cannot
override inherited
member 'System.Collections.Specialized.NameObjectCollection
Base.GetEnumerator()' because it is not marked virtual,
abstract, or override"
So the question is: why doesn't it marked as virtual if it
does??
Thanks!
 
So the question is: why doesn't it marked as virtual if it
does??

It must be a documentation bug -
NameObjectCollectionBase.GetEnumerator is sealed so you can't override
it.



Mattias
 
It must be a documentation bug -
NameObjectCollectionBase.GetEnumerator is sealed so you can't override
it.

You are right. Ildasm.exe shows that it's [Final] and
[Virtual] at the same time. But for what purpose might it
be done (I mean sealed and new virtual)?
 
But for what purpose might it
be done (I mean sealed and new virtual)?

The fact that it's virtual in IL just means that it overrides the base
method. final means it cannot be further overridden.



Mattias
 
Back
Top