Writing to standard output from c# program

3.3k Views Asked by At

I have the following C# code

class Test 
{
    public static void Main(String[] argv) 
    { 
        Console.WriteLine("Hello "); 
    }
}

When I run the program from the command prompt, I do not see output. The c# file name is file.cs and compiles into file.exe.

When I run this from the command prompt:

c:\>file.exe

I do not see any output. But it works if I run this:

c:\>file.exe | more

I understand I need to do something other that console.WriteLine(). Is there any way that I can redirect all Console.WriteLine() calls to standard output?

1

There are 1 best solutions below

0
On

Application type was set to Windows application in Visual Studio project properties. I set the application type to "Console". This fixed the issue. Now all Console.WriteLine statements gets printed to command window.