次の方法で共有


Console.OpenStandardInput メソッド (Int32)

指定したバッファ サイズに設定された標準入力ストリームを取得します。

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

パラメータ

  • bufferSize
    内部ストリーム バッファ サイズ。

戻り値

標準入力ストリーム。

例外

例外の種類 条件
ArgumentOutOfRangeException bufferSize の値が 0 以下です。

解説

このメソッドは、 SetIn メソッドによって変更された後に、標準出力ストリームを再取得するために使用できます。

使用例

OpenStandardInput の使用方法については、次のコード例を参照してください。

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

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard

参照

Console クラス | Console メンバ | System 名前空間 | Console.OpenStandardInput オーバーロードの一覧 | In | SetIn