 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check if Input, Output and Error is redirected on the Console or not in C#
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
Advertisements
 