Aaron Chapman
Aaron Chapman

Reputation: 57

Console.Write(string) no longer works in a VS 2017 WinForms project?

Anyone have any ideas why Console.Write(string) no longer works in a Visual Studio 2017 C# Windows Forms application?

Here's some sample code to reproduce:

Console.WriteLine("Results: ");
const int count = 15;
for (int i = 0; i < count; i++)
{
    if (i == (count - 1))
        Console.Write(i);
    else
        Console.Write(i + ", ");
}

I've already submitted a bug to the VS team at Microsoft and they've been less than helpful. They don't seem to understand the issue for some reason? I don't know how to be any more clear than this right here.

Bug report: https://developercommunity2.visualstudio.com/t/consolewritestring-does-not-work-anymore/1241476

Upvotes: 0

Views: 834

Answers (2)

Aaron Chapman
Aaron Chapman

Reputation: 57

Microsoft has changed the functionality of their product, and they've done so without many people even noticing because it's such a niche case scenario... Just as @Jimi stated in his comment above.

You mean Visual Studio's Output Panel, of course (?). Or Immediate Window, depending on your configuration. If that's the case, this happened a while ago and went on for some time. It has been solved (or, better, the default behavior has been restored) many versions before the current.

Upvotes: 0

Jamshaid K.
Jamshaid K.

Reputation: 4587

It is not going to work as a winforms project will not create console window in here. If you want to see it the console output, you need to open integrated Output window of visual studio.

Step 1
Click on View in the navigation menu of Visual studio.

Step 2
Then click Output or you can use the shortcut Ctrl+W, O to open the window for you.

View Menu

Step 3

Now, replace all the Console.WriteLines(...); with Debug.WriteLines(...); which will put all the lines that you want to output.

Upvotes: 2

Related Questions