
- 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
How to change the Foreground Color of Text in C# Console?
To change the Foreground Color of text, use the Console.ForegroundColor property in C#.
Example
Let us see an example −
using System; class Demo { public static void Main (string[] args) { Console.BackgroundColor = ConsoleColor.Blue; Console.WriteLine("Background color changed = "+Console.BackgroundColor); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("
Foreground color changed = "+Console.ForegroundColor); } }
Output
This will produce the following output −
- Related Articles
- How to change the Foreground color or Font color of the console using PowerShell?
- How to change the Background Color of Text in C# Console
- How to change JLabel background and foreground color in Java?
- How can we change the background and foreground color of a JTooltip in Java?
- How to change the text color of an element in HTML?
- How to change the text color of Menu item in Android?
- How to change the color of selected text using CSS?
- How to change text cursor color in Tkinter?
- How to change the selection color of text in IText using FabricJS?
- How to change the font color of a text using JavaScript?
- How to change the text color of font in the legend using Matplotlib?
- How to Change Link Underline Color using text-decoration-color CSS
- How to change the Text color of Menu item in Android using Kotlin?
- How to change the color of certain words in a Tkinter text widget?
- How to change the WindowLeft of the Console

Advertisements