Question Color

porkshopp

Active member
Joined
Apr 13, 2019
Messages
26
Location
Sweden
Programming Experience
Beginner
How can I make an item in my array a specific color?
C#:
 Bo[answer - 1] = "X"; Console.ForegroundColor = ConsoleColor.Green;
 
You're going to have to be more specific. Are you simply saying that you want to display the next text you write to the console in a particular colour or you want a specific element in an array to always be displayed in a specific colour?
 
I want to edit a specific element in the array and set a colored text, but it should only be that element that has that color, the others should not be impacted. So if I have an array that outputs: "A", "B", "C". It should now output "A", "B", "C" but the B is green. This should also be done inside another method
 
A String has no colour so you will need to store the colour along with the text somehow and then, whenever you display a text value, you do so using the associated colour. For instance, you might define a class with a property of type String and another of type ConsoleColor and store instances of that in an array instead of just Strings.
 
Back
Top Bottom