Console.In Console.In Console.In Console.In Property

定義

標準入力ストリームを取得します。Gets the standard input stream.

public:
 static property System::IO::TextReader ^ In { System::IO::TextReader ^ get(); };
public static System.IO.TextReader In { get; }
member this.In : System.IO.TextReader
Public Shared ReadOnly Property In As TextReader

プロパティ値

標準入力ストリームを表す TextReader オブジェクト。A TextReader that represents the standard input stream.

次の例は、の使用方法を示します、Inプロパティ。The following sample illustrates the use of the In property.

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);
    }
}
Imports System
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 'Main
End Class 'InTest

注釈

このプロパティは、既定で標準入力ストリームに設定です。This property is set to the standard input stream by default. 別のストリームにこのプロパティを設定することができます、SetInメソッド。This property can be set to another stream with the SetIn method.

標準入力ストリームの読み取り操作が同期的に実行します。Read operations on the standard input stream execute synchronously. つまり、指定された読み取り操作が完了するまでブロックします。That is, they block until the specified read operation has completed. これはあっても当てはまる場合、非同期メソッドなどReadLineAsyncが呼び出される、TextReaderによって返されるオブジェクト、Inプロパティ。This is true even if an asynchronous method, such as ReadLineAsync, is called on the TextReader object returned by the In property.

適用対象

こちらもご覧ください