数组 class 中没有 Empty<T> 方法?

No Empty<T> method in Array class?

Error pic

为什么编译器告诉我它不存在?我最后安装了 SDK 并将 netcoreapp3.1 作为目标框架。

public SomeDefinedType[] GetRecords()
{
        return new System.Array.Empty<SomeDefinedType>();
}

Array.Empty() 是一个函数,return 是一个空数组,而不是一个类型。它不能与 new 一起使用。只是 return 函数的结果:

public SomeDefinedType[] GetRecords()
{
    return System.Array.Empty<SomeDefinedType>();
}