Storing color in a string c#
Posted: Wed Mar 21, 2012 10:35 pm
Is it at all possible to store color inside of a string variable? so lets say for instance i have a game board that looks like this
And all the spaces are normal color except for the P, say i want the P to be blue. Is there anyway to store this inside of a string variable? Because right now my board update looks like:
I use stringbuilder to create one long string variable with a \n for a new line every 80 characters, however this method does not let me assign color to individual characters in the string. Any suggestions to either a new board writing method or a way to store color inside the string method?
Code: Select all
#################
#
# P
#
#################
Code: Select all
static public void boardWrite()
{
Console.Clear();
board.Remove(0, board.Length);
for (int y = 0; y < 20; y++)
{
int i = 0;
for (int x = 0; x < 80; x++)
{
i++;
if (i < 80)
{
board.Append(tiles[x, y]);
}
else
{
board.Append("\n");
i = 0;
}
}
}
Console.Write(board);
}