为什么固定大小缓冲区不支持非托管类型

  • 本文关键字:不支持 类型 缓冲区 c# .net
  • 更新时间 :
  • 英文 :


这样的东西不会编译,即使泛型类型的大小是恒定的

public unsafe struct CornerData<T> where T : unmanaged {
private fixed T _data[4]; // CS1663: Fixed size buffer type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double [Assembly-CSharp]
}

为什么固定大小的缓冲区不允许unmanaged关键字包含其他类型,或者这可能是引入关键字时的疏忽吗?

看起来它被遗漏了,但现在正在中

https://github.com/dotnet/csharplang/blob/9586b1e3388e367d62c2d3314306c4ed6920d873/proposals/fixed-sized-buffers.md

最新更新