Can't override base virtual method

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!
 
M

Mattias Sjögren

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
 
E

Ed

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)?
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top