
This is an alarm program. It sets off an audible alarm after a certain number of minutes. This can be useful for timers, such as those required in cooking. It uses the Console in the C# language. Simplicity is key.
This example C# console program sets off an alarm after a number of minutes.

To begin, this is the entire alarm console program. The program simply asks for the number of minutes. It converts this to a string with the int.Parse method. Then, it waits sixty seconds using Thread.Sleep for each minute, and writes some characters to the screen. Finally it beeps ten times.
int.Parse for Integer Conversion Sleep Method Pauses Programs Beep ExampleExample alarm program [C#]
using System;
using System.Threading;
class Program
{
static void Main()
{
// Ask for minutes.
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Minutes?");
string minutes = Console.ReadLine();
int mins = int.Parse(minutes);
for (int i = 0; i < mins; i++)
{
// Sixty seconds is one minute.
Thread.Sleep(1000 * 60);
// Write line.
Console.WriteLine(new string('X', 30));
}
// Beep ten times.
for (int i = 0; i < 10; i++)
{
Console.Beep();
}
Console.WriteLine("[Done]");
Console.Read();
}
}
This program is extremely simple. The simplicity makes it easy to maintain and understand but not very fancy to use. For common tasks that require a timer, this program can be useful. Obviously, a more elaborate solution could be found using Windows Forms and sound effects.
Console Programs