So I'm trying to find a simple code that makes my code get printed in bold. When I searched the internet all of them were so complicated that it wasn't even worth it. Is there any easier way to make a string or just a Console.WriteLine(" "); bold?
Console.Write("Type in the number of people to create: ");
int time = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nGenerating " + time + " people please stand by...");
System.Threading.Thread.Sleep(3000);
Console.Clear();
You can use the ANSII escape codes, as long as your console supports it.
You can do basics like, color text, background and bold,underline and reverse colors. for example in c#
Console.WriteLine("\x1b[1mTEST\x1b[0m");
will print it in bold \\x1b[0m
one at the end is to reset the formatting, many formatting options are made by changing the number after the bracket.
look into these links, I have used it with C and Python in bash, but I'm not sure about C# at the moment.
https://www.jerriepelser.com/blog/using-ansi-color-codes-in-net-console-apps/
ANSI-Coloring Console Output with .NET
This link has all the codes for ANSII escape codes, I have used it in C, so It may need some modifications.
http://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html
Fonts and Styles are not available on a per-word basis.(@Atreyagaurav)
But You Can Set Console.ForegroundColor
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("This Is A Test Txt"); // Print Text In Red Color
Console.ResetColor();
Or Alternatively, You Can Change cmd Font Setting
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.
But you can set the Console.ForegroundColor, Console.BackgroundColor
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.