A
Andrew McCall
Hi,
I am a (bad) C++ programmer, and I thought I would learn C# so I can
play with Microsoft XNA Game Studio Express. I haven't picked up any
C# books yet, but have been reading articles around the web until I get
chance to get to a shop.
I am a little stuck on creating my get and set methods, using the
article here:
http://www.c-sharpcorner.com/Code/2003/July/CSharpMethodsIntro.asp
I thought I would start off by creating a simple OXO game, but my set
method isn't working. I am getting the error "Error 1 The name 'value'
does not exist in the current context ".
Can someone help me out please?
My code is below:
namespace ExtremeOXO
{
class OXOBoard
{
enum OXOTile
{
EmptyTile,
XTile,
OTile
};
OXOTile[,] oxotOXOGameBoard = new OXOTile[3, 3];
public OXOBoard()
{//OXOBoard()
Console.WriteLine("Entering OXOBoard() Constructor");
InitializeBoard();
OutputBoard();
Console.WriteLine("Leaving OXOBoard() Constructor");
}//OXOBoard()
public void InitializeBoard()
{//InitializeBoard()
Console.WriteLine("Entering InitializeBoard()");
for (int iCountX=0; iCountX < 3; iCountX++)
{//For
for (int iCountY = 0; iCountY < 3; iCountY++)
{//For
Console.WriteLine("Clear tile {0},{1} here when set
works.....",iCountX,iCountY);
}//For
}//For
Console.WriteLine("Leaving InitializeBoard()");
}//InitializeBoard()
void set(int x, int y)
{
oxotOXOGameBoard[x, y] = value;
}
OXOTile get(int x, int y)
{
return oxotOXOGameBoard[x, y];
}
}
}
I am a (bad) C++ programmer, and I thought I would learn C# so I can
play with Microsoft XNA Game Studio Express. I haven't picked up any
C# books yet, but have been reading articles around the web until I get
chance to get to a shop.
I am a little stuck on creating my get and set methods, using the
article here:
http://www.c-sharpcorner.com/Code/2003/July/CSharpMethodsIntro.asp
I thought I would start off by creating a simple OXO game, but my set
method isn't working. I am getting the error "Error 1 The name 'value'
does not exist in the current context ".
Can someone help me out please?
My code is below:
namespace ExtremeOXO
{
class OXOBoard
{
enum OXOTile
{
EmptyTile,
XTile,
OTile
};
OXOTile[,] oxotOXOGameBoard = new OXOTile[3, 3];
public OXOBoard()
{//OXOBoard()
Console.WriteLine("Entering OXOBoard() Constructor");
InitializeBoard();
OutputBoard();
Console.WriteLine("Leaving OXOBoard() Constructor");
}//OXOBoard()
public void InitializeBoard()
{//InitializeBoard()
Console.WriteLine("Entering InitializeBoard()");
for (int iCountX=0; iCountX < 3; iCountX++)
{//For
for (int iCountY = 0; iCountY < 3; iCountY++)
{//For
Console.WriteLine("Clear tile {0},{1} here when set
works.....",iCountX,iCountY);
}//For
}//For
Console.WriteLine("Leaving InitializeBoard()");
}//InitializeBoard()
void set(int x, int y)
{
oxotOXOGameBoard[x, y] = value;
}
OXOTile get(int x, int y)
{
return oxotOXOGameBoard[x, y];
}
}
}