国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#控制臺應(yīng)用程序中輸出彩色字體

2020-01-24 00:39:11
字體:
供稿:網(wǎng)友

本文實例為大家分享了C#控制臺輸出彩色字體的具體代碼,供大家參考,具體內(nèi)容如下

using System;class Example{ public static void Main()  {  // Get a string array with the names of ConsoleColor enumeration members.  String[] colorNames = ConsoleColor.GetNames(typeof(ConsoleColor));  // Display each foreground color except black on a constant black background.  Console.WriteLine("All the foreground colors (except Black) on a constant black background:");  foreach (string colorName in colorNames)  {   // Convert the string representing the enum name to the enum value.   ConsoleColor color = (ConsoleColor) Enum.Parse(typeof(ConsoleColor), colorName);   if (color == ConsoleColor.Black) continue;   Console.Write("{0,11}: ", colorName);   Console.BackgroundColor = ConsoleColor.Black;   Console.ForegroundColor = color;   Console.WriteLine("This is foreground color {0}.", colorName);   // Restore the original foreground and background colors.   Console.ResetColor();  }  Console.WriteLine();  // Display each background color except white with a constant white foreground.  Console.WriteLine("All the background colors (except White) with a constant white foreground:");  foreach (string colorName in colorNames)  {   // Convert the string representing the enum name to the enum value.   ConsoleColor color = (ConsoleColor) Enum.Parse(typeof(ConsoleColor), colorName);   if (color == ConsoleColor.White) continue;   Console.Write("{0,11}: ", colorName);   Console.ForegroundColor = ConsoleColor.White;   Console.BackgroundColor = (ConsoleColor) Enum.Parse(typeof(ConsoleColor), colorName);   Console.WriteLine("This is background color {0}.", colorName);   Console.ResetColor();  } }}

效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 靖边县| 阿克陶县| 葫芦岛市| 延川县| 运城市| 佛山市| 安龙县| 瑞昌市| 泾阳县| 日照市| 平安县| 抚顺县| 青川县| 宽城| 阿克陶县| 连州市| 卓尼县| 吐鲁番市| 鲁山县| 龙南县| 阿尔山市| 中阳县| 嵩明县| 樟树市| 金沙县| 凌源市| 渭南市| 台南市| 望奎县| 西华县| 治县。| 乌苏市| 浙江省| 安丘市| 洪雅县| 鄢陵县| 洛隆县| 彰武县| 寿阳县| 大石桥市| 曲沃县|