I have some code where I\'m returning an array of objects.
Here\'s a simplified example:
string[] GetTheStuff() {
List s = null;
Others have answered your question nicely. So just a simple point to make...
I'd avoid returning an array (unless you can't). Stick with IEnumerable and then you can use Enumerable.Empty
from the LINQ APIs. Obviously Microsoft have optimised this scenario for you.
IEnumerable GetTheStuff()
{
List s = null;
if (somePredicate())
{
var stuff = new List();
// load data
return stuff;
}
return Enumerable.Empty();
}