Given a normal Console in C#, the task is to play Beep sound through the Console.
Approach: This can be achieved with the help of Beep() method of Console Class in System package of C#.
The Beep() method of Console Class is used to play a Beep sound through the Console speaker.
Syntax: public static void Beep ();
Exceptions: This method throws HostProtectionException if this method was executed on a server, such as SQL Server, that does not permit access to a user interface.
Below programs show the use of Console.Beep() method:
Program 2: Play Beep sound n number of times.
Note: Please run the programs on offline Visual Studio to experience the output.
- C# | How to play user modified Beep sound through Console
- Console Class in C#
- Console.KeyAvailable() Property in C#
- Console.ResetColor() Method in C#
- Console.SetError() Method in C#
- C# | How to change Title of the Console
- C# | How to change the WindowTop of the Console
- Console.ReadKey() Method in C#
- Console.OpenStandardInput Method in C#
- Console.SetCursorPosition() Method in C#
- Console.Read() Method in C#
- C# | How to change the CursorSize of the Console
- Console.SetBufferSize() Method in C#
- C# | How to change the WindowLeft of the Console
- Console.MoveBufferArea Method in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.