PDA

Click to See Complete Forum and Search --> : How to check if a string array has been initialized **SOLVED**


Sgt-Peppa
Jun 2nd, 2004, 07:32 AM
Hey all, this seems to be easy but I cant seem to figure out how to check if a string array has already been initialized?

If I have public string [] attachments; defined in my class.

No I want to check if the array has got any values in it, but if I do,

if (attachments.Length !=0)

I get an error saying:
Object reference not set to an instance of an object.

So how do I check if my array has already been initialized or not?

Thanks Stephan

Tewl
Jun 2nd, 2004, 07:55 AM
try checking if attachments == null

Sgt-Peppa
Jun 2nd, 2004, 07:59 AM
I knew it was easy, but that easy,......:blush:
This is so emberassing, must be a very bad coding day for me,...

Thanks a lot,

it works (of course it does,.....)

Stephan