Console.OpenStandardInput Method in C# Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share 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://learn.microsoft.com/en-us/dotnet/api/system.console.openstandardinput?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article Console.ReadLine() 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 Like