Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Console.In Property

Gets the standard input stream.

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

Property Value

A TextReader that represents the standard input stream.

Remarks

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

Example

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

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

Requirements

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

Show:
© 2015 Microsoft