C#控制臺(tái)輸出彩色字體的代碼

本篇文章展示了C#控制臺(tái)輸出彩色字體的具體代碼,代碼簡明扼要容易理解,如果在日常工作遇到這個(gè)疑問。希望大家通過這篇文章,找到解決疑問的辦法。

站在用戶的角度思考問題,與客戶深入溝通,找到岳陽樓網(wǎng)站設(shè)計(jì)與岳陽樓網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋岳陽樓地區(qū)。

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#控制臺(tái)輸出彩色字體的代碼

關(guān)于C#控制臺(tái)輸出彩色字體的代碼就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識(shí)。如果喜歡這篇文章,不如把它分享出去讓更多的人看到。

新聞名稱:C#控制臺(tái)輸出彩色字體的代碼
網(wǎng)頁路徑:http://muchs.cn/article28/jpiojp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、自適應(yīng)網(wǎng)站、用戶體驗(yàn)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站收錄商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化