Это фрагменты кода, относящиеся к вопрос:
Код: Выделить всё
string foregroundColor = "White";
string backgroundColor = "Black";
testMap1(ref map, foregroundColor, backgroundColor);
static void testMap1(ref string[,] map, string foregroundColor, string backgroundColor)
{
resetMap(ref map, foregroundColor, backgroundColor);
foregroundColor = "Red";
backgroundColor = "Black";
static void resetMap(ref string[,] map, string foregroundColor, string backgroundColor)
{
foregroundColor = "White";
backgroundColor = "Black";
static void displayPosition2(ref string[,] map, int[] place, string foregroundColor, string backgroundColor)
{
if (foregroundColor == "Red")
{
Console.ForegroundColor = ConsoleColor.Red;
}
else if (foregroundColor == "Green")
{
Console.ForegroundColor = ConsoleColor.Green;
}
else if (foregroundColor == "Yellow")
{
Console.ForegroundColor = ConsoleColor.Yellow;
}
else if (foregroundColor == "Magenta")
{
Console.ForegroundColor = ConsoleColor.Magenta;
}
else if (foregroundColor == "DarkGreen")
{
Console.ForegroundColor = ConsoleColor.DarkGreen;
}
else if (foregroundColor == "Black")
{
Console.ForegroundColor = ConsoleColor.Black;
}
else if (foregroundColor == "Blue")
{
Console.ForegroundColor = ConsoleColor.Blue;
}
else if (foregroundColor == "Cyan")
{
Console.ForegroundColor = ConsoleColor.Cyan;
}
else if (foregroundColor == "DarkBlue")
{
Console.ForegroundColor = ConsoleColor.DarkBlue;
}
else if (foregroundColor == "DarkCyan")
{
Console.ForegroundColor = ConsoleColor.DarkCyan;
}
else if (foregroundColor == "DarkGrey")
{
Console.ForegroundColor = ConsoleColor.DarkGray;
}
else if (foregroundColor == "DarkMagenta")
{
Console.ForegroundColor = ConsoleColor.DarkMagenta;
}
else if (foregroundColor == "DarkRed")
{
Console.ForegroundColor = ConsoleColor.DarkRed;
}
else if (foregroundColor == "DarkYellow")
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
}
else if (foregroundColor == "Gray")
{
Console.ForegroundColor = ConsoleColor.Gray;
}
else
{
Console.ForegroundColor = ConsoleColor.White;
}
Я хотелось бы знать, почему это не работает так, как задумано, все, с кем я разговаривал в реальной жизни, говорили, что это должно работать.
Подробнее здесь: https://stackoverflow.com/questions/783 ... fter-its-d