編譯器錯誤 CS0209
更新:2007 年 11 月
錯誤訊息
在 fixed 陳述式中宣告的區域變數型別必須為指標型別
您在 fixed 陳述式中所宣告的變數必須是一個指標。如需詳細資訊,請參閱Unsafe 程式碼和指標 (C# 程式設計手冊)。
下列範例會產生 CS0209:
// CS0209.cs
// compile with: /unsafe
class Point
{
public int x, y;
}
public class MyClass
{
unsafe public static void Main()
{
Point pt = new Point();
fixed (int i) // CS0209
{
}
// try the following lines instead
/*
fixed (int* p = &pt.x)
{
}
fixed (int* q = &pt.y)
{
}
*/
}
}