N
Narshe
I have a collection class that inherits from CollectionBase, and
implements IBindingList, and I'm having problems with recursion or List
not having an instance.
This is a simple version of the class.
public class MyCollection : CollectionBase, IBindingList
{
public int Add( object value )
{
return this.List.Add( value );
}
}
This causes an infinite loop when trying to add to the collection, and
I think it's because IBindingList implements IList, so it keeps calling
itself.
So I pass the actual class object type in instead.
public class MyCollection : CollectionBase, IBindingList
{
public int Add( MyClass value )
{
return this.List.Add( value );
}
}
When I do this, List either will give an error about a null reference,
or it will return void and not add anything to the list.
I've seen this done all over the place, but it doesn't seem to be
working for me.
Am I doing this wrong?
implements IBindingList, and I'm having problems with recursion or List
not having an instance.
This is a simple version of the class.
public class MyCollection : CollectionBase, IBindingList
{
public int Add( object value )
{
return this.List.Add( value );
}
}
This causes an infinite loop when trying to add to the collection, and
I think it's because IBindingList implements IList, so it keeps calling
itself.
So I pass the actual class object type in instead.
public class MyCollection : CollectionBase, IBindingList
{
public int Add( MyClass value )
{
return this.List.Add( value );
}
}
When I do this, List either will give an error about a null reference,
or it will return void and not add anything to the list.
I've seen this done all over the place, but it doesn't seem to be
working for me.
Am I doing this wrong?