If an array is empty, it looks like you can\'t check it\'s length using \".length\". What\'s the best way to check if an array is empty?
Jon Skeet answered correctly. Just remember that the order of the test in the "IF" is important.
Check for the null
before the length. I also prefer to put the null
on the left side of the equal which is a habit I got from Java that made the code more efficient and fast… I don't think it's important in a lot of application today, but it's a good practice!
if (null == array || array.Length == 0)