Array empty (ARCH603)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.performance.array-empty · Severity warning · Category performance
Creating a new empty array allocates each time; Array.Empty<T>() returns a single cached instance.
Incorrect
Section titled “Incorrect”public int[] GetIds() => new int[0];Correct
Section titled “Correct”public int[] GetIds() => Array.Empty<int>();Use Array.Empty<T>() for empty arrays.