欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2017年05月26日 10:05:43   作者:雲(yún)霏霏  
這篇文章主要為大家詳細介紹了C#控制臺應(yī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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#逐行讀取文件的方法

    C#逐行讀取文件的方法

    這篇文章主要介紹了C#逐行讀取文件的方法,針對較大文件的讀取非常實用,需要的朋友可以參考下
    2015-07-07
  • C#給圖片添加水印完整實例

    C#給圖片添加水印完整實例

    這篇文章主要介紹了C#給圖片添加水印的方法,以完整實例形式分析了C#實現(xiàn)文字及圖像水印、縮略圖、圖片剪切等相關(guān)技巧,需要的朋友可以參考下
    2015-12-12
  • C#獲取局域網(wǎng)MAC地址的簡單實例

    C#獲取局域網(wǎng)MAC地址的簡單實例

    這篇文章主要介紹了C#獲取局域網(wǎng)MAC地址的簡單實例,有需要的朋友可以參考一下
    2013-11-11
  • c#中switch case的用法實例解析

    c#中switch case的用法實例解析

    這篇文章主要介紹了c#中switch case的用法實例解析,對于C#的初學(xué)者來說有必要熟練掌握,需要的朋友可以參考下
    2014-08-08
  • 分享WCF聊天程序--WCFChat實現(xiàn)代碼

    分享WCF聊天程序--WCFChat實現(xiàn)代碼

    無意中在一個國外的站點下到了一個利用WCF實現(xiàn)聊天的程序,作者是:Nikola Paljetak。研究了一下,自己做了測試和部分修改,感覺還不錯,分享給大家
    2015-11-11
  • C#語法糖(Csharp Syntactic sugar)大匯總

    C#語法糖(Csharp Syntactic sugar)大匯總

    首先需要聲明的是“語法糖”這個詞絕非貶義詞,它可以給我?guī)矸奖?,是一種便捷的寫法,編譯器會幫我們做轉(zhuǎn)換;而且可以提高開發(fā)編碼的效率,在性能上也不會帶來損失。這讓java開發(fā)人員羨慕不已,呵呵。
    2010-06-06
  • C#實現(xiàn)航班查詢及預(yù)訂功能

    C#實現(xiàn)航班查詢及預(yù)訂功能

    這篇文章給大家介紹利用C#完成航班機票信息查詢,航班機票預(yù)定等功能。代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友參考下吧
    2018-02-02
  • C# cefSharep控件的使用詳情

    C# cefSharep控件的使用詳情

    本文主要介紹了C# cefSharep控件的使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • c# 計算時間間隔的簡單方法(推薦)

    c# 計算時間間隔的簡單方法(推薦)

    下面小編就為大家?guī)硪黄猚# 計算時間間隔的簡單方法(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-08-08
  • Winform ComboBox如何獨立繪制下拉選項的字體顏色

    Winform ComboBox如何獨立繪制下拉選項的字體顏色

    這篇文章主要介紹了Winform ComboBox如何獨立繪制下拉選項的字體顏色,幫助大家更好的理解和使用c# winform,感興趣的朋友可以了解下
    2020-11-11

最新評論