NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
# 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]; } } } ```