Export (0) Print
Expand All

Console.OpenStandardInput Method (Int32)

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

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

public static Stream OpenStandardInput (
	int bufferSize
)
public static Stream OpenStandardInput (
	int bufferSize
)
public static function OpenStandardInput (
	bufferSize : int
) : Stream

Parameters

bufferSize

The internal stream buffer size.

Return Value

The standard input stream.

Exception typeCondition

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 code example illustrates the use of the OpenStandardInput property.

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));
    }
}

public class Decoder
{
    public static void main(String[] args)
    {
        Stream inputStream = Console.OpenStandardInput();
        ubyte bytes[] = new ubyte[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.get_UTF7().GetChars(bytes, 0, outputLength);
        Console.WriteLine("Decoded string:");
        Console.WriteLine(new String(chars));
    } //main
} //Decoder

var inputStream : Stream = Console.OpenStandardInput();
var bytes : byte[] = 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\")");
var outputLength : int = inputStream.Read(bytes, 0, 100);
var chars : char[] = Encoding.UTF7.GetChars(bytes, 0, outputLength);
Console.WriteLine("Decoded string:");
Console.WriteLine(chars);

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft