This documentation is archived and is not being maintained.

Console.OpenStandardInput Method (Int32)

.NET Framework 1.1

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

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

Parameters

bufferSize
The internal stream buffer size.

Return Value

The standard input stream.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException bufferSize is less than or equal to zero.

Remarks

This method can be used to reacquire the standard output 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: