Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write boldface text using Console.WriteLine (C#) or printfn (F#)?

Is there a quick way to write boldface text using Console.WriteLine (C#) or printfn (F#)?

If not boldface, perhaps some other kind of visual differentiator, like underlined text?

like image 734
Shredderroy Avatar asked Feb 28 '13 06:02

Shredderroy


People also ask

How do you make text bold in C#?

Text = GetMOValue(moDisk, "systemname"); txtType. Text = GetMOValue(moDisk, "MediaType"); txtModel. Text = GetMOValue(moDisk, "Model"); txtFirmware.

What is use of console WriteLine () method?

WriteLine(String, Object, Object) Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.

What is the syntax to print a text in the console?

To print a message to the console, we use the WriteLine method of the Console class. The class represents the standard input, output, and error streams for console applications.

Where does console WriteLine write to?

Console. writeline() goes to a console window: the black command / dos prompt.


1 Answers

You can set the Console.ForegroundColor. Click the link, there is a very good example provided in the MSDN.

Fonts and Styles are not available on a per-word basis. To get bold, italics, underline or size, you would have to change all text in the Console.

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Test Text");

Console.ForegroundColor = ConsoleColor.Blue;
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine("Test Text 2");

Console.ResetColor(); // To return colors back
like image 114
nvoigt Avatar answered Sep 24 '22 14:09

nvoigt