It's spring break, so let's beep in C# code, actually a 440 Hz A. We are just borrowing the Beep() function from the Windows kernel.
Beeping
// using InteropServices
// the necessary WinApi functions are in kernel32.dll
// in C# Handle = IntPtr DWORD = uint WORD = int
// just a console program compiled with:
// C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe
using System;
using System.Runtime.InteropServices; // DllImport()
class Class1
{
// WinApi Beep() is in kernel32.dll
[DllImport("kernel32")]
private static extern int Beep(int dwFreq, int dwDuration);
static void Main(string[] args)
{
Console.WriteLine("It's spring time so let's beep!!!!\n\n");
int freq = 440; // hertz
int duration = 2000; // milliseconds
Console.WriteLine("Beeping at " + freq + " Hz for " + duration + " milliseconds");
Beep(freq, duration);
}
}
HLA91 -3 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.