Console.SetIn Method (TextReader)


Sets the In property to the specified TextReader object.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

[<HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)>]
static member SetIn : 
        newIn:TextReader -> unit


Type: System.IO.TextReader

A stream that is the new standard input.

Exception Condition

newIn is null.


The caller does not have the required permission.

By default, the In property is set to the standard input stream.

A StreamReader that encapsulates a FileStream can be used to receive input from a file.

The following example illustrates the use of the SetIn method. It replaces four consecutive space characters in a string with a tab character. To run it, you must supply two command line arguments. The first is the name of an existing text file to redirect the standard input stream to. The second is the name of a file to redirect the standard output stream to. This file need not exist. If it does, its contents will be overwritten.

No code example is currently available or this language may not be supported.


for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top