Console.OpenStandardInput Method

Definition

Acquires the standard input stream.

Overloads

OpenStandardInput()

Acquires the standard input stream.

OpenStandardInput(Int32)

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

OpenStandardInput()

Source:
Console.cs
Source:
Console.cs
Source:
Console.cs

Acquires the standard input stream.

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.IO.Stream OpenStandardInput ();
[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 ();
public static System.IO.Stream OpenStandardInput ();

Returns

The standard input stream.

Attributes

Examples

The following example illustrates the use of the OpenStandardInput method.

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

Remarks

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

See also

Applies to

.NET 9 およびその他のバージョン
製品 バージョン
.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, 8, 9
.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, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1

OpenStandardInput(Int32)

Source:
Console.cs
Source:
Console.cs
Source:
Console.cs

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

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

Parameters

bufferSize
Int32

This parameter has no effect, but its value must be greater than or equal to zero.

Returns

The standard input stream.

Attributes

Exceptions

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.

See also

Applies to

.NET 9 およびその他のバージョン
製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.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, 4.8.1
.NET Standard 2.0, 2.1