add null to collectionbase derivation

  • Thread starter Thread starter John B
  • Start date Start date
J

John B

I changed my code to replace an arraylist with a collection derived from
collectionbase to get type-safe calls. Now though, I cannot seem to add a
null value to the collection, where I could previously with an arraylist. Am
I doing something wrong? Is there a way around it?

Thx
 
John B said:
I changed my code to replace an arraylist with a collection derived from
collectionbase to get type-safe calls. Now though, I cannot seem to add
a null value to the collection, where I could previously with an
arraylist. Am I doing something wrong? Is there a way around it?

Stating actual errors I've found is quite useful when requesting help.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
Here is the class:

public class ControlCollection : CollectionBase
{
public void Add(Control control)
{
base.List.Add(control);
...
}

....
}

and here is the error when control is null:

ArguementNullException was unhandled
Value can not be null.
Parameter name: value

Thanks
---
 
you can't add a null to strongly typed collection, it is only going to
accept objects of the type required, a null value does not have a typed
defined.

HTH

Ollie Riches


John B said:
Here is the class:

public class ControlCollection : CollectionBase
{
public void Add(Control control)
{
base.List.Add(control);
...
}

...
}

and here is the error when control is null:

ArguementNullException was unhandled
Value can not be null.
Parameter name: value

Thanks
=----
 
Back
Top