Export (0) Print
Expand All

Console.OpenStandardInput Method

Acquires the standard input stream.

Overload List

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;

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

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

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

See Also

Console Class | Console Members | System Namespace

Show:
© 2014 Microsoft