CollectionBase in Net1.1 and Collection in Net 2.0

P

Polo

Hi,

I have some collections that inherit from CollectionBase in Net 1.1
In these collection I override the OnRemove, OnRemoveComplete, ...
I would like to to move them in Net 2.0 but in this version these protected
methods don't exist
What is the best way?

Thank's in advance
 
W

Willy Denoyette [MVP]

CollectionBase has not changed, these overrides are still there. What makes
you think they don't exist any longer?

Willy.
 
P

Polo

In fact the protected methods OnRemove, OnRemoveComplete don't exist in the
generic collection
I would like to move to the generic base class of my collections but in my
original collection I override the OnRemove, ...
 
A

Adam Clauss

I just made a quick Windows Form app in C# Express.
Added a class derived from CollectionBase and added an override for
"protected override void OnRemove(int index, object value)"

Compiled just fine. Why do you think it does not exist?
 
A

Adam Clauss

I just noticed the word "generic" in your post, sorry missed that.

Exactly which class are you attempting to derive from, (because
CollectionBase itself has not changed)?
 
P

Polo

I have :

using System.Collections;
public class MyCollection : CollectionBase
{
....
override protected void OnInsertComplete(int Index, object Value)
{
.....
}
....
}

I would like to have :

using System.Collections.Generic;
public class MyCollection : Collection
{
....
override protected void OnInsertComplete(int Index, object Value)
//This method doesn't exist
{
.....
}
....
}
 
S

Sean Hederman

Thats because Collection is not intended to be inherited from, you're
supposed to use CollectionBase.
 

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