🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Compiler Error CS1716 不要使用“System.Runtime.CompilerServices.FixedBuffer”特性。请改用“fixed”字段修饰符。 在包含与字段声明相似的固定大小的数组声明的不安全代码段中,会发生此错误。不要使用此特性。请改用关键字 **fixed**。 下面的示例生成 CS1716。 ``` // CS1716.cs // compile with: /unsafe using System; using System.Runtime.CompilerServices; public struct UnsafeStruct { [FixedBuffer(typeof(int), 4)] // CS1716 unsafe public int aField; // Use this single line instead of the above two lines. // unsafe public fixed int aField[4]; } public class TestUnsafe { static int Main() { UnsafeStruct us = new UnsafeStruct(); unsafe { if (us.aField[0] == 0) return us.aField[1]; else return us.aField[2]; } } } ```