C#控制臺(tái)應(yīng)用程序中輸出彩色字體
本文實(shí)例為大家分享了C#控制臺(tái)輸出彩色字體的具體代碼,供大家參考,具體內(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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
上一篇:C#基于OLEDB獲取Excel文件表結(jié)構(gòu)信息的方法
欄 目:C#教程
下一篇:WinForm實(shí)現(xiàn)頁面按鈕定時(shí)隱藏功能
本文標(biāo)題:C#控制臺(tái)應(yīng)用程序中輸出彩色字體
本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/5723.html
您可能感興趣的文章
- 01-10C#通過反射獲取當(dāng)前工程中所有窗體并打開的方法
 - 01-10C#實(shí)現(xiàn)Winform中打開網(wǎng)頁頁面的方法
 - 01-10C#實(shí)現(xiàn)由四周向中心縮小的窗體退出特效
 - 01-10Extjs4如何處理后臺(tái)json數(shù)據(jù)中日期和時(shí)間
 - 01-10C#中DataGridView常用操作實(shí)例小結(jié)
 - 01-10C#編程獲取資源文件中圖片的方法
 - 01-10C#使用windows服務(wù)開啟應(yīng)用程序的方法
 - 01-10asp.net中XML如何做增刪改查操作
 - 01-10C#利用反射技術(shù)實(shí)現(xiàn)去掉按鈕選中時(shí)的邊框效果
 - 01-10C#中查找Dictionary中的重復(fù)值的方法
 


閱讀排行
本欄相關(guān)
- 01-10C#通過反射獲取當(dāng)前工程中所有窗體并
 - 01-10關(guān)于ASP網(wǎng)頁無法打開的解決方案
 - 01-10WinForm限制窗體不能移到屏幕外的方法
 - 01-10WinForm繪制圓角的方法
 - 01-10C#實(shí)現(xiàn)txt定位指定行完整實(shí)例
 - 01-10WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動(dòng)新
 - 01-10C#停止線程的方法
 - 01-10C#實(shí)現(xiàn)清空回收站的方法
 - 01-10C#通過重寫Panel改變邊框顏色與寬度的
 - 01-10C#實(shí)現(xiàn)讀取注冊表監(jiān)控當(dāng)前操作系統(tǒng)已
 
隨機(jī)閱讀
- 08-05DEDE織夢data目錄下的sessions文件夾有什
 - 08-05織夢dedecms什么時(shí)候用欄目交叉功能?
 - 04-02jquery與jsp,用jquery
 - 01-10C#中split用法實(shí)例總結(jié)
 - 01-11ajax實(shí)現(xiàn)頁面的局部加載
 - 01-10使用C語言求解撲克牌的順子及n個(gè)骰子
 - 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
 - 01-10delphi制作wav文件的方法
 - 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
 - 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
 


