A program has been developed over the past few days, and the program itself is very simple. The general function is to enter query conditions, and retrieve results from the database for calculation and display. However, you must use the console to implement functions. Because of its simple functions, the program was quickly completed. When demonstrating the program for users, I suddenly felt that the display of the program was unfriendly and it was all black and white. Although the functional demonstration required by the user is successful, the font color in the console looks uncomfortable when too many results are displayed. After the demo, you are ready to modify the font color. After searching through the internet, we found that the implementation in C # is very simple, and only a few lines of code are required.
The Code is as follows:
Console. BackgroundColor = ConsoleColor. Blue; // you can specify the background color.
Console. ForegroundColor = lelecolor. White; // set the foreground color, that is, the font color.
Console. WriteLine ("the first line is white blue .");
Console. ResetColor (); // set the foreground color and background color of the Console to the default value.
Console. BackgroundColor = ConsoleColor. Green;
Console. ForegroundColor = ConsoleColor. DarkGreen;
String value = "the third line is green and dark green ";
Console. WriteLine (value. PadRight (Console. WindowWidth-value.Length); // you can specify the background color for the entire row.
The display effect is as follows:
Displays the background color and foreground color supported in the console.
Type type = Console. ForegroundColor = (name Console. BackgroundColor = Console. BackgroundColor = (name Console. ForegroundColor =}
Fonts supported in the console