This documentation is archived and is not being maintained.

Console.OpenStandardInput Method ()

Acquires the standard input stream.

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

'Declaration
Public Shared Function OpenStandardInput As Stream
'Usage
Dim returnValue As Stream

returnValue = Console.OpenStandardInput
public static Stream OpenStandardInput ()
public static function OpenStandardInput () : Stream

Return Value

The standard input stream.

This method can be used to reacquire the standard input 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 Shared Sub Main()
      Dim inputStream As Stream = Console.OpenStandardInput()
      Dim bytes(100) As Byte
      Console.WriteLine("To decode, type or paste the UTF7 encoded string and press enter:")
      Console.WriteLine("(Example: ""M+APw-nchen ist wundervoll"")")
      Dim outputLength As Integer = inputStream.Read(bytes, 0, 100)
      Dim chars As Char() = Encoding.UTF7.GetChars(bytes, 0, outputLength)
      Console.WriteLine("Decoded string:")
      Console.WriteLine(New String(chars))
   End Sub 'Main
End Class 'Decoder

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
Show: