- Learn C# in 7 days
- Gaurav Aroraa
- 118字
- 2021-07-08 09:51:23
Color
Console background and/or foreground color can be changed using setter and getter properties that accept the value of the ConsoleColor enum. To set it to the default color, there is a Reset method. Let's demonstrate all color combinations using the following code:
private static (int, int) DisplayColorMenu(ConsoleColor[] colors) { var count = 0; foreach (var color in colors) { WriteLine($"{count}{color}"); count += 1; } WriteLine($"{count + 1} Reset"); WriteLine($"{count + 2} Exit"); Write("Choose Foreground color:"); var foreground = Convert.ToInt32(ReadLine()); Write("Choose Background color:"); var background = Convert.ToInt32(ReadLine()); return new ValueTuple<int, int>(background, foreground); }
The preceding code is one snippet from the complete source code that is available on the GitHub repository. The complete code will provide the following output:

推薦閱讀
- PHP動態網站程序設計
- 玩轉Scratch少兒趣味編程
- AngularJS Testing Cookbook
- 零起步玩轉掌控板與Mind+
- Arduino by Example
- jQuery從入門到精通 (軟件開發視頻大講堂)
- Internet of Things with Intel Galileo
- 從學徒到高手:汽車電路識圖、故障檢測與維修技能全圖解
- Access 2016數據庫管
- Drupal 8 Module Development
- Python機器學習基礎教程
- Getting Started with Greenplum for Big Data Analytics
- PHP編程基礎與實例教程
- SQL Server 2008中文版項目教程(第3版)
- Node.js應用開發