Console.In プロパティ
標準入力ストリームを取得します。
Public Shared ReadOnly Property In As TextReader
[C#]
public static TextReader In {get;}
[C++]
public: __property static TextReader* get_In();
[JScript]
public static function get In() : TextReader;
プロパティ値
標準入力ストリームを表す TextReader オブジェクト。
解説
既定では、このプロパティは標準入力ストリームに設定されます。このプロパティは、 SetIn メソッドで別のストリームに設定できます。
使用例
In の使用方法については、次の例を参照してください。
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
[C#]
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);
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
void main()
{
TextReader* tIn = Console::In;
TextWriter* tOut = Console::Out;
tOut->WriteLine(S"Hola Mundo!");
tOut->Write(S"What is your name: ");
String* name = tIn->ReadLine();
tOut->WriteLine(S"Buenos Dias, {0}!", name);
}
[JScript]
import System;
import System.IO;
var tIn : TextReader = Console.In;
var tOut : TextWriter = Console.Out;
tOut.WriteLine("Hola Mundo!");
tOut.Write("What is your name: ");
var name : String = tIn.ReadLine();
tOut.WriteLine("Buenos Dias, {0}!", Object(name));
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard
参照
Console クラス | Console メンバ | System 名前空間 | Error | Out | SetIn