Export (0) Print
Expand All

Console.OpenStandardInput Method ()

.NET Framework 1.1

Acquires the standard input stream.

[Visual Basic]
Overloads Public Shared Function OpenStandardInput() As Stream
[C#]
public static Stream OpenStandardInput();
[C++]
public: static Stream* OpenStandardInput();
[JScript]
public static function OpenStandardInput() : Stream;

Return Value

The standard input stream.

Remarks

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

Example

The following code sample illustrates the use of OpenStandardInput:

[Visual Basic] 
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

[C#] 
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));
    }
}

[C++] 
int main() {
    Stream* inputStream = Console::OpenStandardInput();
    Byte bytes[] = new Byte[100];
    Console::WriteLine(S"To decode, type or paste the UTF7 encoded string and press enter:");
    Console::WriteLine(S"(Example: \"M+APw-nchen ist wundervoll\")");
    int outputLength = inputStream->Read(bytes, 0, 100);
    Char chars[] = Encoding::UTF7->GetChars(bytes, 0, outputLength);
    Console::WriteLine(S"Decoded string:");
    Console::WriteLine(new String(chars));
}

[JScript] 
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);

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

Console Class | Console Members | System Namespace | Console.OpenStandardInput Overload List | In | SetIn

Show:
© 2015 Microsoft