Collections - Documentation

A

Adam Dockter

I am working with collection so naturally I have a class this is inheriting
from collection base.

The documentation based on .net framework v 1.1 has both Count and
GetEnumerator declared as virtual.

However when I go to override these methods I get the compiler error stating
that I cannot use override because the properties/methods were not declaired
as virtual, override or abstract.

Has anyone else ran into this? Is there a patch for it or am I just up a
creek?

Thanks
Adam dR.
 
J

Jon Skeet [C# MVP]

Adam Dockter said:
I am working with collection so naturally I have a class this is inheriting
from collection base.

The documentation based on .net framework v 1.1 has both Count and
GetEnumerator declared as virtual.

However when I go to override these methods I get the compiler error stating
that I cannot use override because the properties/methods were not declaired
as virtual, override or abstract.

Has anyone else ran into this? Is there a patch for it or am I just up a
creek?

It's a mistake in the documentation - they're not virtual.
 
N

Nicholas Paldino [.NET/C# MVP]

Adam,

The Count property is not overridable, even though the documentation
says it is. The same goes for the GetEnumerator method.

If you need to override these, then you should implement the IList
interface from scratch.

Hope this helps.
 

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