Console.OpenStandardInput Method (Int32)

 

Acquires the standard input stream, which is set to a specified buffer size.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)]
public static Stream OpenStandardInput(
	int bufferSize
)

Parameters

bufferSize
Type: System.Int32

The internal stream buffer size.

Return Value

Type: System.IO.Stream

The standard input stream.

Exception Condition
ArgumentOutOfRangeException

bufferSize is less than or equal to zero.

This method can be used to reacquire the standard output stream after it has been changed by the SetIn method.

The following example illustrates the use of the OpenStandardInput property.

using System;
using System.Text;
using System.IO;

public class Decoder {
    public static void Main() {
        Stream inputStream = Console.OpenStandardInput();
        byte[] bytes = new byte[100];
        Console.WriteLine("To decode, type or paste the UTF7 encoded string and press enter:");
        Console.WriteLine("(Example: \"M+APw-nchen ist wundervoll\")");
        int outputLength = inputStream.Read(bytes, 0, 100);
        char[] chars = Encoding.UTF7.GetChars(bytes, 0, outputLength);
        Console.WriteLine("Decoded string:");
        Console.WriteLine(new string(chars));
    }
}

.NET Framework
Available since 1.1
Return to top
Show: