- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to play user modified Beep sound through Console in C#?
To play user modified beep sound through Console, the code is as follows −
Example
using System; public class Demo { public static void Main(String[] args){ Console.WriteLine("Displaying standard output stream..."); Console.WriteLine("Standard Output Stream = "+Console.Out); Console.WriteLine("Beep sound through Console"); Console.Beep(); Console.WriteLine("Beep sound through Console with frequence 1000 hertz and duration 500 milliseconds"); Console.Beep(1000, 500); } }
Output
This will produce the following output −
Displaying standard output stream... Standard Output Stream = System.IO.TextWriter+SyncTextWriter Beep sound through Console Beep sound through Console with frequence 1000 hertz and duration 500 milliseconds
Example
Let us now see another example −
using System; public class Demo { public static void Main(String[] args){ int freq = 1500; int duration = 1000; Console.WriteLine("Displaying standard output stream..."); Console.WriteLine("Standard Output Stream = "+Console.Out); Console.WriteLine("Beep sound through Console"); Console.Beep(); Console.WriteLine("Beep sound through Console with frequency 1000 hertz and duration 500 milliseconds"); Console.Beep(1000, 500); Console.WriteLine("Playing Beep sound 10 times..."); for (int i = 1; i < 10; i++) Console.Beep(freq, duration); } }
Output
This will produce the following output −
Displaying standard output stream... Standard Output Stream = System.IO.TextWriter+SyncTextWriter Beep sound through Console Beep sound through Console with frequency 1000 hertz and duration 500 milliseconds Playing Beep sound 10 times...
Advertisements