正确例题<背景颜色>
using System;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
Type type = typeof(ConsoleColor);
Console.ForegroundColor = ConsoleColor.White;
foreach (var name in Enum.GetNames(type))
{
Console.BackgroundColor = (ConsoleColor)Enum.Parse(type, name);
Console.WriteLine(name);
}
Console.BackgroundColor = ConsoleColor.Black;
foreach (var name in Enum.GetNames(type))
Console.ReadLine();
}
}
}
正确例题<背景颜色>
using System;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
Type type = typeof(ConsoleColor);
Console.ForegroundColor = ConsoleColor.White;
foreach (var name in Enum.GetNames(type))
{
Console.BackgroundColor = (ConsoleColor)Enum.Parse(type, name);
Console.WriteLine(“你好”);
}
}
}
}