共用方式為


Console.In 屬性

定義

取得標準輸入資料流。

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

屬性值

TextReader,代表標準輸入資料流。

屬性

範例

下列範例說明 屬性的使用 In

using namespace System;
using namespace System::IO;
int 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 );
}
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 ,也是如此。

適用於

另請參閱