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




















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version