Console.In Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient le flux d’entrée standard.
public:
static property System::IO::TextReader ^ In { System::IO::TextReader ^ get(); };
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.IO.TextReader In { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.IO.TextReader In { get; }
public static System.IO.TextReader In { get; }
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member In : System.IO.TextReader
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member In : System.IO.TextReader
static member In : System.IO.TextReader
Public Shared ReadOnly Property In As TextReader
Valeur de propriété
Qui TextReader représente le flux d’entrée standard.
- Attributs
Exemples
L’exemple suivant illustre l’utilisation de la In propriété.
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
Remarques
Cette propriété est définie sur le flux d’entrée standard par défaut. Cette propriété peut être définie sur un autre flux avec la SetIn méthode.
Les opérations de lecture sur le flux d’entrée standard s’exécutent de manière synchrone. Autrement dit, ils bloquent jusqu’à ce que l’opération de lecture spécifiée soit terminée. Cela est vrai même si une méthode asynchrone, telle que ReadLineAsync, est appelée sur l’objet TextReader retourné par la In propriété.