英語で読む

次の方法で共有


Console.OpenStandardInput メソッド

定義

標準入力ストリームを取得します。

オーバーロード

OpenStandardInput()

標準入力ストリームを取得します。

OpenStandardInput(Int32)

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

OpenStandardInput()

標準入力ストリームを取得します。

C#
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.IO.Stream OpenStandardInput ();
C#
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.IO.Stream OpenStandardInput ();
C#
public static System.IO.Stream OpenStandardInput ();

戻り値

Stream

標準入力ストリーム。

属性

OpenStandardInputメソッドの使用例を次に示します。

C#
using System;
using System.Text;
using System.IO;

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

注釈

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

こちらもご覧ください

適用対象

.NET 7 およびその他のバージョン
製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

OpenStandardInput(Int32)

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

C#
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.IO.Stream OpenStandardInput (int bufferSize);
C#
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public static System.IO.Stream OpenStandardInput (int bufferSize);
C#
public static System.IO.Stream OpenStandardInput (int bufferSize);

パラメーター

bufferSize
Int32

このパラメーターには影響はありませんが、その値は 0 以上である必要があります。

戻り値

Stream

標準入力ストリーム。

属性

例外

bufferSize が 0 以下です。

注釈

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

こちらもご覧ください

適用対象

.NET 7 およびその他のバージョン
製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1