共用方式為


編譯器警告 (層級 1) CS1522

更新:2007 年 11 月

錯誤訊息

空白 switch 區塊

編譯器偵測到一個沒有 casedefault 陳述式的 switch 區塊。switch 區塊必須有一或多個 casedefault 陳述式。

下列範例會產生 CS1522:

// CS1522.cs
// compile with: /W:1
using System;
class x
{
   public static void Main()
   {
      int i = 6;

      switch(i)   // CS1522
      {
         // add something to the switch block, for example:
         /*
         case (5):
            Console.WriteLine("5");
            return;
         default:
            Console.WriteLine("not 5");
            return;
         */
      }
   }
}