共用方式為


編譯器錯誤 CS0230

更新:2007 年 11 月

錯誤訊息

型別和識別項兩者都需要在 Foreach 陳述式

foreach 陳述式的格式不完整。

下列範例會產生 CS0230:

// CS0230.cs
using System;

class MyClass
{
   public static void Main()
   {
      int[] myarray = new int[3] {1,2,3};

      foreach (int in myarray)   // CS0230
      // try the following line instead
      // foreach (int x in myarray)
      {
         Console.WriteLine(x);
      }
   }
}