最佳解决方案的代码:
1 static void Main(string[] args) 2 { 3 Console.ForegroundColor = ConsoleColor.Green; 4 Console.WriteLine("Hello, color text!"); 5 Console.ForegroundColor = ConsoleColor.Red; 6 Console.WriteLine("Hello, color text!"); 7 Console.ReadKey(); 8 }
效果如图: