Erica <(E-Mail Removed)> wrote:
> Ok, I have noticed that some people here are using the method 'SomeType[]
> thisVar = new SomeType[0];' I guess that so the array is empty but not null
> and prevents any NullReferenceException from occuring. The string class has
> 'string.Empty' and since the Array class is the base class for arrays, then
> maybe it would be nice to have something like Array.Empty. Then I could do
> 'SomeType[] thisVar = Array.Empty;' that would be nice.
What exact type would Array.Empty be declared to return? You'd have to
pass in the type of the array you're interested in, at which point you
might as well just do new SomeType[0]; or new SomeType[]{}
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too