C# Console Beep() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Console

Definition

In C#, Console.Beep asks the system to play a short alert sound. The parameterless call uses a default beep.

An overload accepts frequency (Hz) and duration (milliseconds). Support varies by platform—some environments ignore Beep or only allow the default sound. Treat it as a nice-to-have signal, not a guaranteed audio API.

This is a static member of System.Console. You call it with the type name, such as Console.Beep(...). Console is the everyday API for reading from standard input and writing to standard output in C# console apps.

Syntax

Call Beep() or Beep(frequency, duration) on supported systems.

C#
Console.Beep();
Console.Beep(800, 200);
CallWhat it does
Console.Beep()Default system beep.
Console.Beep(800, 200)About 800 Hz for 200 ms when supported.

Beep may be platform-limited or silent. Do not rely on it for critical feedback alone.

Library declarations
C#
public static void Beep();
public static void Beep(int frequency, int duration);

Parameters

ParameterDescription
frequencyOptional. Pitch in hertz (typical useful range roughly 37–32767 on Windows).
durationOptional. Length in milliseconds.

Return Value

Return ValueDescription
voidNothing is returned; a sound may play.

C# Examples

Example 1 — Beep After a Message

Print a notice, then play the default beep.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine("Task finished");
        Console.Beep();
        Console.WriteLine("(beep)");
    }
}

How It Works

  1. Message first. Users still see text even if sound is off.
  2. Default Beep. No frequency arguments—system default tone.
  3. Marker line. We print (beep) because sound cannot appear in sample output.
  4. Optional cue. Treat audio as secondary feedback.

Example 2 — Two Different Pitches

Play a short low tone then a higher one when supported.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine("Low tone");
        Console.Beep(400, 150);
        Console.WriteLine("High tone");
        Console.Beep(1000, 150);
    }
}

How It Works

  1. Frequency. 400 Hz then 1000 Hz when the platform allows it.
  2. Duration. 150 ms keeps each beep short.
  3. Text labels. Output shows which tone was requested.
  4. May be silent. Some hosts skip custom Beep calls.

Example 3 — Beep on Invalid Input

Combine validation text with a beep.

C#
using System;

class Program {
    static void Main() {
        Console.Write("Enter YES: ");
        string? s = Console.ReadLine();
        if (s != "YES") {
            Console.Beep();
            Console.WriteLine("Invalid");
        } else {
            Console.WriteLine("Accepted");
        }
    }
}

How It Works

  1. Sample nope. User types something other than YES.
  2. Beep on error. Sound (if any) pairs with the Invalid message.
  3. Visible fallback. Text always communicates the failure.
  4. Strict match. Comparison is case-sensitive here.

Frequently Asked Questions

No. Support depends on the OS and host. It may be silent.
Frequency is hertz; duration is milliseconds.
Invalid frequency/duration values can throw. Unsupported environments may also fail or no-op.
Only as an extra cue. Always show a clear text message too.
No. Write prints text; Beep requests a sound.

Next: Clear()

Clear the console screen buffer and reset the cursor to the home position with System.Console.

Clear() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful