I'm currently having a hard time swapping two variables. I'd like to be able swap values once the user enters a value which is next to a blank cell Apologies for my extremely messy code, I'm just picking up C#.
static void SwapNums(string[,] theBoard)
{
int col, row;
string swap;
string number = ReadNumber();
for (col = 0; col if (theBoard[col, row] == "")
{
theBoard[col, row] = number;
}
}
}
}
}
}
}
} < 6; col++)
{
for (row = 0; row < 6; row++)
{
if (theBoard[col,row] == number)
{
if (theBoard[col + 1, row] == "-" || theBoard[col - 1, row] == "-" || theBoard[col, row + 1] == "" || theBoard[col, row - 1] == "-")
{
swap = theBoard[col, row];
theBoard[col, row] = "";
for (col = 0; col < 6; col++)
{
for (row = 0; row < 6; row++)
{
if (theBoard[col, row] == "")
{
theBoard[col, row] = number;
}
}
}
}
} if (theBoard[col, row] == "")
{
theBoard[col, row] = number;
}
}
}
}
}
}
}
}
}
}
}
At the moment, this code is replacing the blank cellwith what the user entered, but is not replacing the cell that contains the number to p.