dimanche 28 novembre 2021

How do i change the foreground color of a console in c# with a if statement

I want to change the color of the text in a c# console to blue if a person says their favorite color is blue.

using System;

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

        Console.Title = ("Favorite Color");
       

        Console.WriteLine("What is your favorite color?");

        string favoriteColor = (Console.ReadLine());

        if (favoriteColor == "Blue")
        {
            Console.ForegroundColor = ConsoleColor.Blue;
        }
    
        Console.ReadKey();
    }

}

}

Aucun commentaire:

Enregistrer un commentaire