共用方式為


編譯器錯誤 CS1629

更新:2007 年 11 月

錯誤訊息

Unsafe 程式碼不可出現在 Iterator 中

C# 語言規格不允許 Iterator 中出現 Unsafe 程式碼。

下列範例會產生 CS1629:

// CS1629.cs
// compile with: /unsafe  
using System.Collections.Generic;
class C 
{
   IEnumerator<int> IteratorMeth() {
      int i;
      unsafe  // CS1629
      {
         int *p = &i;
         yield return *p;
      }
   }
}