Just trying to learn Tasks and using Console.WriteLine in win app but no output

Lloyd Sheen 1,481 Reputation points
2023-02-20T22:18:49.6633333+00:00

Title pretty much says it. I've tried Console.WriteLine and Debug.WriteLine and they show no where VS 2022.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,176 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 31,086 Reputation points Microsoft Vendor
    2023-02-22T03:32:29.47+00:00

    Hello @Lloyd Sheen ,

    Welcome to Microsoft Q&A forum.

    My understanding win app is just a category of project types including WinForms, WPF, WinUI etc. I tested WinUI app as an example based on your previous issues. I reproduced the issue in WinUI project in VS2022.

    Actually, the Console.WriteLine isn’t for IDE output windows. It writes to console. But, as you know, the default output type for WinUI is windows application. Here’re some workarounds, you can try to achieve it:

    1. If you want to use Debug.WriteLine to output ,you should build in debug mode. It will show the message/text in your output window that show output from Debug at the bottom of Visual Studio.

    Example

    
    System.Diagnostics.Debug.WriteLine("I am using debugging");
    
    

    User's image

    1. if you want to use Console.WriteLine(), here’s a simple way:

    Right click project and then select : Project Properties -> Application -> Output Type -> Console Application. It can show output in console window.

    example

    
        Console.WriteLine("3233");
    
    

    User's image

    ResultUser's image

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.