C# Console SetIn
Description
Console SetIn
sets the In property to the specified TextReader
object.
Syntax
Console.SetIn
has the following syntax.
[HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)]
public static void SetIn(
TextReader newIn
)
Parameters
Console.SetIn
has the following parameters.
newIn
- A stream that is the new standard input.
Returns
Console.SetIn
method returns
Example
The following example illustrates the use of the SetIn method.
/* w ww. ja va 2 s .c o m*/
using System;
using System.IO;
public class InsertTabs {
public static void Main(){
try {
StreamWriter writer = new StreamWriter("data");
Console.SetOut(writer);
Console.SetIn(new StreamReader("newFile"));
}
catch(IOException e) {
TextWriter errorWriter = Console.Error;
errorWriter.WriteLine(e.Message);
}
}
}