Console.OpenStandardInput Method in C# Last Updated : 05 Mar, 2019 Comments Improve Suggest changes Like Article Like Report Console.OpenStandardInput Method is used to get the standard input stream. There are two overloads of OpenStandardInput method available in C# which are listed below: OpenStandardInput() Method OpenStandardInput(int32) Method OpenStandardInput() Method It is used to get the standard input stream. Make the object of Stream class and by using this method, the user can give the Input reference to that object. It creates a buffer which is used to take user input. This method can also be used to reacquire the standard input stream after it has been changed by the SetIn method. Syntax: public static System.IO.Stream OpenStandardInput (); Example: csharp // C# program to illustrate the // OpenStandardInput() Method using System; using System.Text; using System.IO; class GFG { public static void Main() { // Stream Object declared and // OpenStandardInput method is used Stream inputStream = Console.OpenStandardInput(); byte[] bytes = new byte[50]; int outputLength = inputStream.Read(bytes, 0, 50); char[] chars = Encoding.UTF7.GetChars(bytes, 0, outputLength); Console.WriteLine(new string(chars)); } } Output: OpenStandardInput(Int32) Method It is also used to get the standard input stream which is set to specified buffer size. The value passed in this method determines the size of the buffer. This method can also be used to reacquire the standard input stream after it has been changed by the SetIn method. Syntax: public static System.IO.Stream OpenStandardInput (int bufferSize); Parameters: buffersize: It is the internal stream buffer size. Return Value: It returns the standard input stream. Exception: This method will give ArgumentOutOfRangeException if the buffersize is less than or equal to zero. csharp // C# program to illustrate the // OpenStandardInput(Int32) Method using System; using System.Text; using System.IO; class GFG { // Main Method public static void Main() { // Using the Method Stream inputStream = Console.OpenStandardInput(100); byte[] bytes = new byte[100]; int outputLength = inputStream.Read(bytes, 0, 100); char[] chars = Encoding.UTF7.GetChars(bytes, 0, outputLength); Console.WriteLine(new string(chars)); } } Output: Reference: https://docs.microsoft.com/en-us/dotnet/api/system.console.openstandardinput?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article Console.OpenStandardInput Method in C# R Rajnis09 Follow Improve Article Tags : C# CSharp-method CSharp-Console-Class Similar Reads Console.OpenStandardError Method in C# This method is used to acquire a standard error stream. This method can be used to reacquire the standard error stream after it has been changed by the SetError method. Syntax: public static System.IO.Stream OpenStandardError (); Returns: This method returns the standard error stream. Example: The b 2 min read Console.OpenStandardOutput() Method in C# with Examples Console.OpenStandardOutput Method is used to get the standard output stream. There are two overloads of OpenStandardOutput method available in C# which are listed below: OpenStandardOutput() Method OpenStandardOutput(int32) Method OpenStandardOutput() Method It is used to get the standard output str 2 min read Console.SetIn() Method in C# The Console.SetIn() method is used to set the In property of the specified StreamReader object i.e. it redirects the standard input from the console to the input file. Since the console is set with this StreamReader object, the ReadLine() method can be called to read the contents of the file, line b 2 min read Console.ReadLine() Method in C# This method is used to read the next line of characters from the standard input stream. It comes under the Console class(System Namespace). If the standard input device is the keyboard, the ReadLine method blocks until the user presses the Enter key. And if standard input is redirected to a file, th 2 min read Console.SetOut() Method in C# Console.SetOut(TextWriter) Method in C# is used to redirect the stream of standard output. With the help of this method, a user can specify a StreamWriter as the output object. The Console.SetOut method will receive an object of type TextWriter. The StreamWriter can be passed to Console.SetOut and i 2 min read Console.Read() Method in C# Console.Read() Method is used to read the next character from the standard input stream. This method basically blocks its return when the user types some input characters. As soon as the user press ENTER key it terminates. Syntax: public static int Read (); Return Value: It returns the next characte 1 min read Console.ReadKey() Method in C# Console.ReadKey() Method makes the program wait for a key press and it prevents the screen until a key is pressed. In short, it obtains the next character or any key pressed by the user. The pressed key is displayed in the console window(if any input process will happen). There are two methods in th 5 min read Console.SetError() Method in C# The Console.SetError(TextWriter) Method sets the Error property of the specified StreamWriter i.e., it redirects the standard error stream to a file. As the console is set with this StreamWriter object, the WriteLine() method can be called to write the error into the file. Syntax: public static void 2 min read Console.SetWindowPosition() Method in C# Console.SetWindowPosition(Int32, Int32) Method in C# is used to set the position of the console window relative to the screen buffer. Syntax: public static void SetWindowposition(int left, int top); Parameters: left: It is the column position of the upper left corner of the console window. top: It i 1 min read Console.SetCursorPosition() Method in C# Console.SetCursorPosition(Int32, Int32) Method is used to set the position of cursor. Basically, it specifies where the next write operation will begin in the console window. The window origin changes automatically to make the cursor visible if the specified cursor position is outside the area that 1 min read Like