---
title: "Three colors repeated in C# Console application"  
description: "Three colors repeated in C# Console application"  
author: "Madam Walker"  
published: 2013-10-05  
updated: 2013-10-05  
canonical: https://www.mindstick.com/forum/1615/three-colors-repeated-in-c-sharp-console-application  
category: "c#"  
tags: ["c#"]  
reading_time: 3 minutes  

---

# Three colors repeated in C# Console application

I am new in C#.

Below is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) this code I have done so far:

\

```
for (int row = 1; row <= 25; row++)        {            for (int col = 1; col <= 39; col++)            {                switch (row)                {                    case 1:                        Console.ForegroundColor = ConsoleColor.Red;                        break;                    case 2:                        Console.ForegroundColor = ConsoleColor.White;                        break;                    case 3:                        Console.ForegroundColor = ConsoleColor.Green;                        break;                }                Console.Write("@ ");        }        Console.WriteLine();}
```

In the above line of code, the first line is [shows](https://yourviews.mindstick.com/view/81380/new-york-violent-shooting-shows-people-are-not-safe-in-night-life) in [red](https://yourviews.mindstick.com/view/81343/lonar-lake-turning-red-again) [color](https://www.mindstick.com/articles/77/how-to-split-form-background-color-in-c-sharp) after that all lines is shows in white color how can I achieve my [task](https://www.mindstick.com/forum/161761/what-is-the-difference-between-task-and-thread) please anybody help me

\

All help is appreciated

Thanks

## Replies

### Reply by Anonymous User

Change your code in switch:

```
for (int row = 1; row <= 25; row++) {
                for (int col = 1; col <= 39; col++)
                {
                    switch (row%3)
                    {
                        case 1:
                            Console.ForegroundColor = ConsoleColor. Red;
                            break;
                        case 2:
                            Console.ForegroundColor = ConsoleColor. White;
                            break;
                        case 0:
                            Console.ForegroundColor = ConsoleColor.Green;
                            break;
                     }
                     Console.Write("@ ");
                    }
                Console.WriteLine();
```


---

Original Source: https://www.mindstick.com/forum/1615/three-colors-repeated-in-c-sharp-console-application

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
