"Michael S" <no@mail.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
"Bill Butler" <qw****@asdf.com> wrote in message news:PlMpf.3489$Ap1.704@trndny06...
<snip> MyClass[] myArray = new MyClass[10];
myArray.Length is 10 and it has 10 null refs in it.
You could argue that myArray is empty even though the Length is 10.
I don't know if this is a condition that you care about or not.
I only bring it up because it would fail the tests given so far.
Bill
I would consider that a bug and not a valid case to test for.
Personally, I avoid arrays with null refs as well, but that does not mean they are a BUG.
Here is a (contrived) example.
I have 10 slots to lease out for a flea market.
I create Vendor[] Vendors = new Vendor[10];
where each array location corresponds to a Physical slot.
As vendors sign up they are assigned to a particular slot
Vendors[slot] = new Vendor(blah);
To check if a slot is available just do
if (Vendors[slot] == null)
Now there might be prettier way to accomplish this, but this does work.
More importantly, it would not be unthinkable that code like this exists in MANY shops.
So, under some situations, it may be a valid case.
Granted, this is not the NORMAL use for arrays, but it is not inconceivable either.
Bill