Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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