共用方式為


編譯器錯誤 CS0022

更新:2007 年 11 月

錯誤訊息

[] 內部的索引數字錯誤,必須是 'number'

陣列存取作業在方括弧內指定了不正確的維度 (Dimension) 數目。如需詳細資訊,請參閱陣列 (C# 程式設計手冊)

範例

下列範例會產生 CS0022:

// CS0022.cs
public class MyClass
{
    public static void Main()
    {
        int[] a = new int[10];
        a[0] = 0;     // single-dimension array
        a[0,1] = 9;   // CS0022, the array does not have two dimensions
    }
}