ICollection implementation

E

Ethan Strauss

Hi,
I have a class which inherits from CollectionBase. I set it up long
ago and it works fine. I just ran FxCop on my project and it wants me to
"provide a strongly typed implementation of ICollection.CopyTo" for that
class. OK, I read some documentation and that looks fairly easy. I just add
code that looks something like

void ICollection.CopyTo(Array array, int index)
{
List.CopyTo(array, index);
}

The problem is that when I do this the compiler gives me the message

:\Inetpub\wwwroot\FlexiComplete\Features\FeatureDefinitionCollection.cs(26):
'FlexiVectorDatabase.FeatureDefinitionCollection.ICollection.CopyTo(System.Array,
int)': containing class does not implement interface
'System.Collections.ICollection'

I checked some more documentation and it really looks to me like a class
which inherits CollectionBase should implement ICollection. I tried adding
methods for SynchRoot, IsSynchronized, and Count, but that didn't help.

I am using C#.Net 1.1
Just so you know, I don't understand interfaces and may be missing something
very basic. If so, please let me know.
Any help with this issue would be appreciated.
Thanks!
Ethan Strauss Ph.D.
Bioinformatics Scientist
Promega Corporation
2800 Woods Hollow Rd.
Madison, WI 53711
608-274-4330
800-356-9526
(e-mail address removed)
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I checked some more documentation and it really looks to me like a class
which inherits CollectionBase should implement ICollection. I tried adding
methods for SynchRoot, IsSynchronized, and Count, but that didn't help.

Do not include ICollection.

declare it like


public void CopyTo(Array array, int index)
{
List.CopyTo(array, index);
}
 

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