Question: I often need to return empty collections.  

One of those days I wrote the following to return a cached instance:

```
public static class Array<T>
{
    // As a static field, it gets created only once for every type.
    public static readonly T[] Empty = new T[0];
}

```

I didn't know about `Enumerable<T>.Empty()` maybe it didn't exist back then. Although I know now, I still use this one.

There are still many functions in BCL that need an array instead of `IEnumerable<T>`, `IList<T>` or `IReadOnlyList<T>`. And array implements all of these so it can be used anywhere.

```
// All these variables share the same array's reference.
string[]            empty1 = Array<string>.Empty;
IEnumerable         empty2 = Array<string>.Empty;
IEnumerable<string> empty3 = Array<string>.Empty;

```

What do you think about this class?  

Can you see any other advantages/disadvantages of it over `Enumerable<T>.Empty()`? 

And about implementation:  

Do you think making the caching using a static field would cause any problem?

---

Edit: Array class now has a static, generic [Empty](https://docs.microsoft.com/dotnet/api/system.array.empty) method, essentially deprecating this implementation.

Answer: 
Your solution is absolutely correct and practical. 

In fact `Enumerable.Empty<T>` also returns empty array under the hood, just slightly in a different way (they have a separate instance holder class that is lazily initialized).
While it most certainly is nifty to save a little bit of time by using cached collections, returning the same empty collection every time an empty collection needs to be returned is digging yourself into a hole:

Consider what happens if the user decides to also 'save a little bit of time' by re-using the collection that your function returned. The empty collection you were returning everywhere would not be empty anymore and the re-used empty collections would cause many bugs.

I would say best practice is to use a memorypool of any kind to pool the collections you use in time-critical code and using that to get the empty collection. This way you achieve the same speed as when returning a cached collection, but without the limitation that the empty collection cannot be used for anything, ever.