How to get the Standard Input and Output Stream through Console in C#?

CsharpServer Side ProgrammingProgramming

To get the standard input stream through Console, the code is as follows −

Example

 Live Demo

using System;
public class Demo {
   public static void Main(string[] args){
      Console.WriteLine("Displaying standard input stream...");
      Console.WriteLine("Standard Input Stream = "+Console.In);
   }
}

Output

This will produce the following output −

Displaying standard input stream...
Standard Input Stream = System.IO.TextReader+SyncTextReader

Example

Let us now see an example to display standard output stream −

 Live Demo

using System;
public class Demo {
   public static void Main(string[] args){
      Console.WriteLine("Displaying standard output stream...");
      Console.WriteLine("Standard Output Stream = "+Console.Out);
   }
}

Output

This will produce the following output −

Displaying standard output stream...
Standard Output Stream = System.IO.TextWriter+SyncTextWriter
raja
Published on 10-Dec-2019 12:22:31
Advertisements