In C#, Array.Empty<T>() returns an empty array of type T[] with length 0. The runtime reuses one shared instance per type, so repeated calls do not allocate a new array every time.
Use it when an API needs an array argument and you have nothing to pass—cleaner and cheaper than new T[0] in hot paths.
This is a static member of System.Array. You call it with the class name, such as Array.Empty(...). Arrays in C# have a fixed length after creation; use List<T> when the count must grow.
Syntax
Call the generic static method and store the result as T[].
Do not write into the empty array. There are no slots. Treat it as read-only length zero.
Library declarations
C#
public static T[] Empty<T>();
Parameters
Parameter
Description
T
Type argument. The element type of the empty array.
Return Value
Return Value
Description
T[]
An empty array of length 0. The same instance may be returned for every call of that T.
C# Examples
Example 1 — Get an Empty Int Array
Print length and show that there are no elements to loop.
C#
using System;
class Program {
static void Main() {
int[] none = Array.Empty<int>();
Console.WriteLine("Length: " + none.Length);
Console.WriteLine("Elements: [" + string.Join(", ", none) + "]");
}
}
Output
Length: 0
Elements: []
How It Works
Generic call.Array.Empty<int>() asks for an empty int array.
Length zero. There are no indexes to read.
Join stays safe.string.Join on an empty sequence prints nothing between brackets.
No allocation churn. Later calls for int can reuse the same instance.
Example 2 — Same Reference for Empty<T>
Two calls return the identical shared array object.
C#
using System;
class Program {
static void Main() {
string[] a = Array.Empty<string>();
string[] b = Array.Empty<string>();
Console.WriteLine(object.ReferenceEquals(a, b));
Console.WriteLine(a.Length);
}
}
Output
True
0
How It Works
ReferenceEquals.True means a and b point to one object.
Per-type cache. Empty string arrays share one instance; empty int arrays share another.
Do not mutate. Changing a “private” empty array would surprise every other caller.
API default. Returning Array.Empty<T>() from a method avoids null and avoids new T[0].
Example 3 — Return Empty Instead of Null
A helper returns an empty array when there is no data—callers can foreach safely.
C#
using System;
class Program {
static string[] GetTags(bool hasTags) {
if (!hasTags) {
return Array.Empty<string>();
}
return new string[] { "csharp", "array" };
}
static void Main() {
string[] tags = GetTags(false);
Console.WriteLine("Count: " + tags.Length);
foreach (string t in tags) {
Console.WriteLine(t);
}
Console.WriteLine("Done");
}
}
Output
Count: 0
Done
How It Works
No null. Callers never need if (tags == null) before looping.
foreach is empty. The loop body never runs when Length is 0.
Clear contract. Empty means “zero items,” which is clearer than null for many APIs.
Cheap default. The shared empty array avoids a fresh allocation on every miss.
Frequently Asked Questions
A T[] with Length 0. The runtime may reuse one shared instance per T.
Yes for defaults and hot paths. Empty avoids repeated allocations and documents “no elements” clearly.
No useful slots exist. Do not treat the shared instance as a private buffer you can fill.
Usually no. Calls for the same T often return the same cached array object.
Prefer Empty (or an empty enumerable) so callers can foreach without null checks.