共用方式為


編譯器錯誤 CS0213

更新:2007 年 11 月

錯誤訊息

您不能使用 fixed 陳述式來取得原本就是 fixed 運算式的位址

unsafe 方法或參數之區域變數已固定 (在堆疊上),因此您無法取得 fixed 運算式中任一個變數的位址。如需詳細資訊,請參閱 Unsafe 程式碼和指標 (C# 程式設計手冊)

範例

下列範例會產生 CS0213。

// CS0213.cs
// compile with: /unsafe
public class MyClass
{
   unsafe public static void Main()
   {
      int i = 45;
      fixed (int *j = &i) { }  // CS0213
      // try the following line instead
      // int* j = &i;

      int[] a = new int[] {1,2,3};
      fixed (int *b = a)
      {
         fixed (int *c = b) { }  // CS0213
         // try the following line instead
         // int *c = b;
      }
   }
}