共用方式為


Console.In 屬性

定義

會接收標準輸入串流。

public:
 static property System::IO::TextReader ^ In { System::IO::TextReader ^ get(); };
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.IO.TextReader In { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.IO.TextReader In { get; }
public static System.IO.TextReader In { get; }
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member In : System.IO.TextReader
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member In : System.IO.TextReader
static member In : System.IO.TextReader
Public Shared ReadOnly Property In As TextReader

屬性值

A TextReader 代表標準輸入串流。

屬性

範例

以下範例說明了該 In 性質的使用方式。

using System;
using System.IO;

class InTest {
    public static void Main() {

        TextReader tIn = Console.In;
        TextWriter tOut = Console.Out;

        tOut.WriteLine("Hola Mundo!");
        tOut.Write("What is your name: ");
        String name = tIn.ReadLine();

        tOut.WriteLine("Buenos Dias, {0}!", name);
    }
}
open System

let tIn = Console.In
let tOut = Console.Out

tOut.WriteLine "Hola Mundo!"
tOut.Write "What is your name: "
let name = tIn.ReadLine()

tOut.WriteLine $"Buenos Dias, {name}!"
Imports System.IO

Class InTest
    
    Public Shared Sub Main()
        Dim tIn As TextReader = Console.In
        Dim tOut As TextWriter = Console.Out
        
        
        tOut.WriteLine("Hola Mundo!")
        tOut.Write("What is your name: ")
        Dim name As [String] = tIn.ReadLine()
        
        tOut.WriteLine("Buenos Dias, {0}!", name)
    End Sub
End Class

備註

此屬性預設設為標準輸入串流。 此屬性可透過 方法 SetIn 設定至另一串流。

標準輸入串流的讀取操作同步執行。 也就是說,它們會阻塞直到指定的讀取操作完成。 即使對該屬性回傳In的物件呼叫TextReader非同步方法ReadLineAsync,如 ,這點依然成立。

適用於

另請參閱