.Net 6 Console app: WebApplication.CreateBuilder vs Host.CreateDefaultBuilder

WebApplication.CreateBuilderpart() is only used for web/api applications like the name implies Host.CreateDefaultBuilder() is used to build a generic host (without web services, middleware etc) which you can use to build anything other than webhost. See for example; https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host Which has not changed. Its true that it feels a bit awkward to build console apps and/or … Read more

Windows Console Application Getting Stuck (Needs Key Press) [duplicate]

If the user accidentally clicks into the black console window, the cursor changes to a filled white rectangle, and the app hangs at the next Console.Write statement, until another clic is made. It is a generic feature of the Console window when its “QuickEdit Mode” is enabled. In order to disable that feature, you should … Read more

Custom text color in C# console application?

The list found at http://msdn.microsoft.com/en-us/library/system.console.backgroundcolor.aspx I believe are the only supported colors in console. No hex allowed. Black DarkBlue DarkGreen DarkCyan DarkRed DarkMagenta DarkYellow Gray DarkGray Blue Green Cyan Red Magenta Yellow White EDIT Get the working project files off my public Repo https://bitbucket.org/benskolnick/color-console/ But on further investigation you can do a lot of work … Read more

Can I get copy/paste functionality from a C# Console Window?

I’ve copied text from the Console window and pasted it into another source many times. It’s there as default in a Console application; Right click the console border: Select Edit > Mark: Drag over the text you want using the mouse (Or use the arrow keys) to select the text you want: Again, right click … Read more

Is Thread.Sleep(Timeout.Infinite); more efficient than while(true){}?

I would recommend using a ManualResetEvent (or other WaitHandle), and calling ManualResetEvent.WaitOne. This will have a similar effect to sleeping forever, except that it provides you a clean way to exit from your infinite “block” when desired (by calling Set() on the event). Using while(true) will consume CPU cycles, so it’s definitely something to avoid. … Read more

Show message Box in .net console application

We can show a message box in a console application. But first include this reference in your vb.net or c# console application System.Windows.Forms; Reference: To add reference in vb.net program right click (in solution explorer) on your project name-> then add reference-> then .Net-> then select System.Windows.Forms. To add reference in c# program right click … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)