Share via


Console.In 属性

获取标准输入流。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public Shared ReadOnly Property In As TextReader
用法
Dim value As TextReader

value = Console.In
public static TextReader In { get; }
public:
static property TextReader^ In {
    TextReader^ get ();
}
/** @property */
public static TextReader get_In ()
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
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);
    }
}
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 );
}
import System.*;
import System.IO.*;

class InTest
{
    public static void main(String[] args)
    {
        TextReader tIn = Console.get_In();
        TextWriter tOut = Console.get_Out();

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

        String name = tIn.ReadLine();
        tOut.WriteLine("Buenos Dias, {0}!", name);
    } //main
} //InTest
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 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

Console 类
Console 成员
System 命名空间
Console.Error 属性
Out
SetIn