“System.IndexOutOfRangeException”类型的异常在 Stores.dll 中发生,但未在用户代码中进行处理

“System.IndexOutOfRangeException”类型的异常在 Stores.dll 中发生,但未在用户代码中进行处理
其他信息: 索引超出了数组界限。

代码: DataTable CreateDataTable(string tablename)
        {
            DataTable tb = new DataTable(tablename);
            int i;
            switch (tablename)
            {
                case "ProductType":
                    for (i = 0; i < 3; i++) tb.Columns.Add(tcn[i], typeof(string));
                    break;
                case "Product":
                    for (i = 0; i < 13; i++) tb.Columns.Add(tcn[i], typeof(string));
                    break;
                case "OrderProduct":
                    for (i = 0; i < 12; i++) tb.Columns.Add(tcn[i], typeof(string));
                    break;
            }
            return tb;
        }

你可能感兴趣的:(“System.IndexOutOfRangeException”类型的异常在 Stores.dll 中发生,但未在用户代码中进行处理)