Using the Console Speaker
Some .NET software, particularly console applications, are executed on computers that do not have sound cards. To provide feedback accompanied by sounds on such machines requires the use of the internal system speaker, or console speaker.
The Console class is a static class that can be found in the System namespace. This class provides methods and properties that can be used to control input and output for console applications, although the members can be used by other application types and libraries too.
The Console class includes a static method named Beep. This method plays simple tones through the internal system speaker, often called the console speaker. The method is ideal for providing audible feedback on systems that do not include a sound card or where the sound card is not connected to speakers. It should be noted, however, that some newer systems do not include a console speaker. Such systems will not emit sound when the Console.Beep method is executed. In addition, some 64-bit systems do not support the Beep method. For such systems, you should play standard windows sounds instead.
The basic syntax for the Beep method requires no parameters. It plays a sound with a frequency of 800 hertz for 200 milliseconds.
A second overloaded version of the Beep method allows you to specify the frequency in hertz and duration of the tone in milliseconds using two integer parameters. The following example plays a sound with a frequency of 262Hz for one second.
30 January 2010