編譯器錯誤 CS1642
更新:2007 年 11 月
錯誤訊息
固定大小緩衝區欄位只能是結構的成員。
如果您在 class 而非 struct 中使用固定大小的緩衝區欄位,便會發生這個錯誤。若要解決這個錯誤,請將 class 變更為 struct,或將欄位宣告為一般陣列。
範例
下列範例會產生 CS1642:
// CS1642.cs
// compile with: /unsafe /target:library
unsafe class C
{
fixed int a[10]; // CS1642
}
unsafe struct D
{
fixed int a[10];
}
unsafe class E
{
public int[] a = null;
}