|
Hi Everyone, I was wondering if someone could help me ....again? I have an array that gets populated with data. Now depending if there is any data, the array may have some items in it or it may not have any at all. I need to find out if the array has items in it, and if it does command 1 will execute, if it doesn't command 2 will execute. My problem is I am having trouble finding out if the array contains any items or not. How do I find out if the array has data? Thanks in advance! Jay |
Loading
JayPosted Sep 5, 2008, 2:58 PM
You are 100% right Alan! You the man once again! Thanks alot!!
Jay
AlanPosted Sep 5, 2008, 1:54 PM
It sounds like your array may be null rather than just empty. Try changing your if condition to this:
if (customPartNumbers != null && customPartNumbers.Length > 0)
JayPosted Sep 5, 2008, 10:35 AM
Hi,
I tried that and I get an error that says "Object reference not set to an instance of an object."
my code looks like....
string[] customPartNumbers = pd.CustomPartNumbers; if (customPartNumbers.Length > 0){
command 1
}
else
{
command2
}
The error points at the argument I have in the IF statement.
Is there something I am missing?
Mahesh ChandPosted Sep 5, 2008, 9:30 AM
Array.Length property will tell you if items are > 0 that means it has data.