
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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
- Related Articles
- Getting the Standard Output and Standard Error Output Stream through Console in C#
- Check if Caps Lock and Num Lock is on or off through Console in C#
- How to get the Standard Input and Output Stream through Console in C#?
- C++ Program to check joke programming code is generating output or not
- Check whether Enter key is pressed or not and display the result in console with JavaScript?
- Check if a number is jumbled or not in C++
- Check if an array is synchronized or not in C#
- Check if a Tree is Isomorphic or not in C++
- How to check if the input date is equal to today’s date or not using JavaScript?
- Check if input is a number or letter in JavaScript?
- Check if a given matrix is sparse or not in C++
- Check if a given number is sparse or not in C++
- Check if a given matrix is Hankel or not in C++
- Check if a directed graph is connected or not in C++
- Check if a number is Quartan Prime or not in C++

Advertisements