webForumDet fria alternativet

Problem med bakgrundsfärg i Console-program

0 svar · 187 visningar · startad av Vimp

VimpMedlem sedan juli 20022 537 inlägg
#1

Jag sitter och leker lite med C# 2.0 nu och försöker ändra bakgrundsfärgen i consolen.
Jag lyckas få en annan bakgrundsfärg bakom texten, men inte i hela consolen.
Någon som har en lösning?

Min nuvarande kod:

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Title = "Testar att ändra titel...";

            Console.WriteLine("Text 1:");
            string String1 = System.Console.ReadLine();

            Console.WriteLine("Text 2:");
            string String2 = System.Console.ReadLine();

            StringBuilder strString = new StringBuilder();
            strString.Append(String1);
            strString.Append(String2);

            Console.WriteLine("Första strängen: {0}", String1);
            Console.WriteLine("Andra strängen: {0}", String2);
            Console.WriteLine("--------------------------------------------------");
            Console.WriteLine("Båda ihoppsatta: {0}", strString);

            Console.ReadLine();

        }
    }
}
132 ms totalt · 3 externa anrop · v20260731065814-full.fb544a5a
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)