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
- Difference between Console.Read and Console.ReadLine in C#
- Difference between Console.Write and Console.WriteLine in C#
- Console Class in C#
- Console.SetWindowPosition() Method in C#
- Console.SetError() Method in C#
- Console.OpenStandardInput Method in C#
- Console.SetIn() Method in C#
- Console.SetOut() Method in C#
- Console.OpenStandardError Method in C#
- Console.SetCursorPosition() Method in C#
- Console.Read() Method in C#
- C# | How to change the CursorLeft of the Console
- C# | How to change BufferHeight of the Console
- C# | How to change Title of the Console
- C# | How to change the WindowTop of the Console
- C# | How to change the WindowLeft of the Console
- C# | How to change the WindowHeight of the Console
- C# | How to change the CursorSize of the Console
- C# | How to change the CursorTop of the Console
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.