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

首頁 > 編程 > C# > 正文

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

2019-10-29 21:10:12
字體:
供稿:網(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();  } }}

效果圖:

C#,控制臺,彩色字體

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


注:相關(guān)教程知識閱讀請移步到c#教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 灵川县| 醴陵市| 汾阳市| 上虞市| 唐河县| 凤冈县| 靖西县| 海安县| 余庆县| 龙江县| 新兴县| 成都市| 尼木县| 开化县| 齐河县| 红河县| 竹山县| 高唐县| 贵南县| 平罗县| 安岳县| 寿宁县| 奎屯市| 武汉市| 五指山市| 江山市| 岳阳市| 泰宁县| 师宗县| 福泉市| 镇坪县| 怀安县| 长兴县| 莱阳市| 龙井市| 桃园市| 乐业县| 怀柔区| 大丰市| 吉隆县| 抚宁县|