To check if the input is redirected on the Console or not, the code is as follows −
Example
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("Input Redirected? = "+Console.IsInputRedirected);
}
}Output
This will produce the following output −
Input Redirected? = False
Example
To check if the output is redirected on the Console or not, the code is as follows −
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("Output Redirected? = "+Console.IsInputRedirected);
}
}Output
This will produce the following output −
Output Redirected? = False
Example
To check if the error is redirected on the Console or not, the code is as follows −
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("Error Redirected on Console? = "+Console.IsErrorRedirected);
}
}Output
This will produce the following output −
Error Redirected on Console? = True