Επεξεργασία

Κοινή χρήση μέσω


Console.In Property

Definition

Gets the standard input stream.

public:
 static property System::IO::TextReader ^ In { System::IO::TextReader ^ get(); };
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.IO.TextReader In { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.IO.TextReader In { get; }
public static System.IO.TextReader In { get; }
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member In : System.IO.TextReader
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member In : System.IO.TextReader
static member In : System.IO.TextReader
Public Shared ReadOnly Property In As TextReader

Property Value

A TextReader that represents the standard input stream.

Attributes

Examples

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);
    }
}
open System

let tIn = Console.In
let tOut = Console.Out

tOut.WriteLine "Hola Mundo!"
tOut.Write "What is your name: "
let name = tIn.ReadLine()

tOut.WriteLine $"Buenos Dias, {name}!"
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
End Class

Remarks

This property is set to the standard input stream by default. 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. This is true even if an asynchronous method, such as ReadLineAsync, is called on the TextReader object returned by the In property.

Applies to

See also