public static void Main()
char[,] img =new char[5,5] {
{' ', ' ', '*', ' ', ' '},
{' ', '*', '*', '*', ' '},
{'*', '*', '*', '*', '*'},
{' ', '*', '*', '*', ' '},
{' ', ' ', '*', ' ', ' '}
public static void fill(char[,] img, int x, int y, char c)
throw new System.ArgumentException("不能大於邊界", "x");
throw new System.ArgumentException("不能小於邊界", "x");
throw new System.ArgumentException("不能大於邊界", "y");
throw new System.ArgumentException("不能小於邊界", "y");
int getXmax = x+1 >img.GetLength(0)?x:x+1;
int getXmin = x-1 <0?0:x-1;
int getYmax = y+1 >img.GetLength(1)?y:y+1;
int getYmin = y-1 <0?0:y-1;
for(int z = getXmin ; z<getXmax;x++){
for(int j = getYmin ; j<getYmax;y++){
public static void PrintImg(char[,] img)
for(int x = 0 ; x<img.GetLength(0);x++){
for(int y = 0 ; y<img.GetLength(1);y++){
Console.WriteLine(printString);