国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 保康县| 区。| 高碑店市| 巴塘县| 同江市| 沁水县| 子洲县| 浦县| 德惠市| 贺兰县| 屏南县| 卢氏县| 张家港市| 锡林浩特市| 陆良县| 陇南市| 历史| 滦南县| 罗江县| 江门市| 绥滨县| 怀来县| 宝山区| 平和县| 百色市| 嘉善县| 东台市| 长宁区| 青川县| 皋兰县| 精河县| 鸡泽县| 龙里县| 洮南市| 伽师县| 遂平县| 东阳市| 赣榆县| 兴义市| 昌乐县| 固原市|