using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program1
{
static void Main(string[] args)
{
public static char[,] board = new char[3,3]; //3x3 board game
public static char? NULL = null; //Null character
public static const int COL = 3; //Max # of columns
public static const int ROW = 3; //Max # of rows
void drawBoard();
}
public void drawBoard() //Method that draws board
{
for(int x = 0; ROW < 3; x++)
{
Console.WriteLine("-------------");
for(int y = 0; COL < 3; y++)
{
Console.Write("|");
if(board[i,j] == NULL)
{
Console.Write(" ");
}
else
{
Console.Write(" " + board[i,j] + " ");
}
}
Console.WriteLine("|");
}
Console.WriteLine("-------------");
}
}
}
我正在嘗試編寫一個井字遊戲。我很新(從幾個小時前開始學習)到C#,所以我不明白爲什麼我的代碼包含錯誤,並且不會編譯。另外,如果可能的話,你能解釋一下在C#中使用命名空間的全部目的嗎?我不太明白名字空間會有什麼不同。提前感謝您的時間和協助。錯誤缺少一個括號,而所有都存在(C#錯誤)
你在使用編譯的「發現的錯誤」的意見(可能錯過了一些)?視覺工作室?如果是這樣,它非常擅長告訴你*正是錯誤所在。如果你不使用VS,爲什麼不呢? –
你從哪裏得到錯誤?什麼是確切的錯誤信息?拋出一堆代碼,並在沒有告訴我們**的情況下說「我得到一個錯誤」**在哪裏**是不恰當的 - 編譯器告訴你它認爲哪一行有問題,所以沒有理由不應該將這些信息傳遞給給我們。 (另外,僅供將來參考:這裏的一般規則是每個帖子有一個問題,因此要求一個完全獨立的問題,並說「雖然你在...」並不太合適。) –
@sgeddes - The上面的代碼仍然格式不正確。這個問題與缺失大括號無關。 –