namespace text_test
{
public class txt_program
{
public class txt
{
/* 0 */
int[] M_array_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 1 */
int[] M_array_1 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 2 */
int[] M_array_2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 3 */
int[] M_array_3 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 4 */
int[] M_array_4 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 5 */
int[] M_array_5 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 6 */
int[] M_array_6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 7 */
int[] M_array_7 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 8 */
int[] M_array_8 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 9 */
int[] M_array_9 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 10 */
int[] M_array_10 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 11 */
int[] M_array_11 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 12 */
int[] M_array_12 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/* 13 */
int[] M_array_13 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int[][] M = { M_array_0, M_array_1 };
}
}
錯誤出現與所述段相關聯:
int[][] M = { M_array_0, M_array_1 };
錯誤涉及M_array_0和M_array_1在上面。我不明白的是爲什麼我無法從上面創建一個多維數組。我應該使用那個代碼? 我嘗試:
string[][] M = { M_array_0, M_array_1 };
double[][] M = { M_array_0, M_array_1 };
錯誤讀取:
甲字段初始不能引用非靜態字段,方法或屬性 'txt_program.txt.M_array_0' text_test \ PSF \首頁\文件\ Visual Studio 2015 \ Projects \ text_test \ text_test \ text.cs 45活動
提前謝謝。
你應該在[構造]設置這些變量(https://msdn.microsoft.com/en-us/library /k6sa6h87.aspx)。 – x13
如果你使數組靜態,這將工作。 – juharr
我已經重新提出了這個問題,因爲它看起來更像鋸齒陣列創建而不是關於錯誤發生。 –