Sprache: C#
Schriftfarbe in der Console ändern
über enums iterieren
.net snippets zum Geburtstag gratulieren 🙂
using System;
using System.Threading;
namespace HappyBirthday
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
foreach (ConsoleColor color in Enum.GetValues(typeof(ConsoleColor)))
{
if (color == ConsoleColor.Black) continue;
Console.ForegroundColor = color;
Thread.Sleep(5 * 10);
Console.Clear();
Console.WriteLine("nnnnnntttHappy 10th birthday dotnet-snippets.de");
}
}
}
}
}
using System;
using System.Threading;
namespace HappyBirthday
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
foreach (ConsoleColor color in Enum.GetValues(typeof(ConsoleColor)))
{
if (color == ConsoleColor.Black) continue;
Console.ForegroundColor = color;
Thread.Sleep(5 * 10);
Console.Clear();
Console.WriteLine("nnnnnntttHappy 10th birthday dotnet-snippets.de");
}
}
}
}
}
Alte URL:
/snippet/schriftfarbe-in-konsolenanwendungen-happy-birthday/14124
Schöner Effekt mit einfachen Mitteln!
Warum
[code]
Thread.Sleep(5 * 10);
[/code]
und nicht
[code]
Thread.Sleep(50);
[/code]
Wegen 10 Jahren dotnet snippets wollte ich die 10 nochmals hervorheben 🙂
Es sollte nicht verwirren. Ich bitte um Entschuldigung 🙂