2013-02-09 9 views
7

IveはWebを検索しましたが、解決策が見つからないようです。私はコンソールアプリケーションウィンドウ全体を特定の色(例えば青色)にしたい。それ、どうやったら出来るの?C#コンソールアプリケーションの背景色を変更します

+1

あなたはどのように検索していますか? [Console.BackgroundColor Property](http://msdn.microsoft.com/en-us/library/system.console.backgroundcolor.aspx) –

+1

黒の背景全体を特定の色にする方法を探していますか?答えを探しているSoner(スクリーンショット付き)は提供されていますか? – bas

+0

試してみると、Console.Clear()を追加するのを忘れるかもしれません。あなたが色をConsole.BackgroundColorに設定した後の行 –

答えて

3

OPの質問は、背景色全体を青色に設定する方法を求めていました。他のサンプルのどれもこれを正しく示していません。ここに方法は次のとおりです。あなたがConsoleColor列挙にConsole.BackgroundColorプロパティを設定することができます

namespace ClearConsole 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      Console.BackgroundColor = ConsoleColor.Blue; 
      Console.Clear(); 

     } 
    } 
} 
5

..

は、コンソールの背景色を取得または設定します。 >コンソールウィンドウ全体の背景色を変更するには、BackgroundColorプロパティを設定し、Clearメソッドを呼び出します。

Console.BackgroundColor = ConsoleColor.Blue; 
Console.Clear(); 

enter image description here

そして、あなたは

ためConsole.ForegroundColorプロパティを使用することができ、コンソールの前景色を取得または設定します。

Console.ForegroundColor = ConsoleColor.Blue; 

enter image description here

+3

@SonerGönül最初のスクリーンショット。そのスクリーンショットの前に 'console.clear();'コマンドがあります。背景全体が青色になるはずです。 –

27

単純に背景色を設定し、Console.Clear()を呼び出す:

class Program { 
    static void Main(string[] args) { 
     Console.BackgroundColor = ConsoleColor.Blue; 
     Console.Clear(); 
     Console.ForegroundColor = ConsoleColor.White; 
     Console.Write("Press any key to continue"); 
     Console.ReadKey(); 
    } 
} 

enter image description here

1
Console.ForegroundColor = Color.Blue; 

Console.WriteLine("This string is blue!");

関連する問題