473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

add null to collectionbase derivation

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
Nov 16 '05 #1
4 1340
"John B" <sp******@hotmail.con> wrote in
news:fu********************@mycybernet.net:
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/
Nov 16 '05 #2
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
---

"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
"John B" <sp******@hotmail.con> wrote in
news:fu********************@mycybernet.net:
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/


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 16 '05 #3
"John B" <sp******@hotmail.con> wrote in news:42**********@127.0.0.1:
ArguementNullException was unhandled
Value can not be null.
Parameter name: value


This is coming from CollectionBase - it probably does not allow nulls as part
of its functionality, which would make sense for a collection.
--
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/
Nov 16 '05 #4
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" <sp******@hotmail.con> wrote in message
news:42**********@127.0.0.1...
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
---

"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
"John B" <sp******@hotmail.con> wrote in
news:fu********************@mycybernet.net:
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/


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet

News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption

=----
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve M | last post by:
I have subclassed CollectionBase. I have also implemented GetEnumerator(). I have tried to set the DataSource of a DataGrid to an instance of my subclass. However, the items in the grid are not...
7
by: m. pollack | last post by:
Hi all, I've been using the CollectionBase class to implement a strongly-typed collection, but I have noticed that the RemoveAt method does not seem to call the "On" hook methods (OnRemove,...
2
by: m.pollack | last post by:
Hi all, I have an application which uses a class object that contains a collection. In order to use the PropertyGrid control to expose properties to the user at runtime, I created a...
3
by: Wells Caughey | last post by:
I am trying to create an XML Schema type definition by deriving from another type definition using restriction. For example suppose my base type was this: <xs:schema <<schema element setup>> >...
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
9
by: Steve Sargent | last post by:
Hi: I'm trying to debug the following code, and it keeps looping on the if statement: public static bool operator == (OnlineMemberNode first, OnlineMemberNode second) { if(first == null) {
2
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count,...
0
by: LIJO CHEERAN | last post by:
Hello friends I am trying to study about CollectionBase. I have inherited CollectionBase in the class TheCollection.cs. I am using the “TheCollection. in an aspx page to store objects...
3
by: Tony Johansson | last post by:
Hello! Sorry for opening up this task again. I want to fully understand this List that is return from CollectionBase. According to you is List in CollectionBase implemented something like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.