This documentation is archived and is not being maintained.

Console.In Property

Gets the standard input stream.

[Visual Basic]
Public Shared ReadOnly Property In As TextReader
public static TextReader In {get;}
public: __property static TextReader* get_In();
public static function get In() : TextReader;

Property Value

A TextReader that represents the standard input stream.


This property is set to the standard input stream by default. This property can be set to another stream with the SetIn method.


The following sample illustrates the use of In:

[Visual Basic] 
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 <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);

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));


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

Console Class | Console Members | System Namespace | Error | Out | SetIn