Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

how can we add separate color for each text

XcrxkXcrxk Member
edited July 2021 in Programming

So my question is how can we add separate color for each text like i want "[1]" in Cyan color and "Calculator" in DarkYellow Color same in "[2]" Cyan and "Story" in DarkYellow..


```using System;

namespace Zortex

{

  class Program

  {

    static void Main(string[] args)

{ Console.ForegroundColor = ConsoleColor.Cyan;

       Console.WriteLine("[1] Calculator");

       Console.WriteLine("[2] Story");

}

}```


**In Python it can be done with colorama like this**


import colorama

from colorama import Fore

from colorama import *


yellow = Fore.MAGENTA

cyan = Fore.CYAN


print(cyan+ "[2]" , yellow + "Calculator")

print(cyan+ "[3]" , yellow + "Story")```


So is there anyway like this to add in c#

Answers

  • QuarkQuark Member
    edited August 2021

    You need to use Console.ForegroundColor before the [2] to change the colour to DarkYellow. Meaning,

    ```using System;


    namespace Zortex


    {


    class Program


    {


    static void Main(string[] args)


    { Console.ForegroundColor = ConsoleColor.Cyan;


    Console.WriteLine("[1] Calculator");

    Console.ForegroundColor = ConsoleColor.DarkYellow;

    Console.WriteLine("[2] Story");


    }


    }```

Sign In or Register to comment.