Modifying Font?

Soli
by Soli · 7 posts
6 years ago in .Net (C#, VB, etc)
Posted 6 years ago · Author
Hello. I'm still working on my C# tutorial and trying to figure everything out. I'm doing pretty well but I would really like to modify the Font color on the Run screen. It would b easier to see my work if I could save certain parts of my work with colored headers in larger or bold font. Can anyone tell me if it's possible and if so, how could I implement it?

Thank you


Image

Image
Image
Posted 6 years ago
@solikaldorei


I don't believe you can change the color of the title but you can change what the title says like this:

Code
Console.Title = "your title here";


As for changing the font color inside the console window, that is possible. You basically change the entire console's font color for the line or lines you want to be a different color then change it back to default.

I personally use a helper method to do it:

Code
static void ColoredConsoleWriteLine(ConsoleColor color, string text)
{
   ConsoleColor originalColor = Console.ForegroundColor;
   Console.ForegroundColor = color;
   Console.WriteLine(text);
   Console.ForegroundColor = originalColor;
}


To use it you simply call it like this whenever you want to write a colored line:

Code
ColoredConsoleWriteLine(ConsoleColor.Red, "my message");


Here's a list of console colors in c#:

Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
DarkYellow
Gray
DarkGray
Blue
Green
Cyan
Red
Magenta
Yellow
White
Posted 6 years ago · Author
@Data. Thank you. I'll try that.
What's the difference between Console.Title and Console.WriteLine? Will title make it look different orbis it just a matter of proper vs improper
Posted 6 years ago
solikaldorei wrote:
@Data. Thank you. I'll try that.What's the difference between Console.Title and Console.WriteLine?


Console.Title sets the text of the window, so instead of saying "C:\Windows\system32\cmd.exe" it will say whatever you tell it you. Console.WriteLine writes a new line of text inside the console.

Normally, you'd only use Console.Title once whereas Console.WriteLine will be used frequently.
Posted 6 years ago · Author
If I'm setting a new section for each part of the tutorial, console and then numbers, do u suggest i keep using writeline like i have been or switch to title?
Posted 6 years ago
solikaldorei wrote:
If I'm setting a new section for each part of the tutorial, console and then numbers, do u suggest i keep using writeline like i have been or switch to title?


Title is only used to set the title of the program window, it doesn't write anything to the screen. Keep using WriteLine.
Posted 6 years ago · Author
Ty. I'll try this later and see if I can get the font to change colors :awesome25:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT