[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Play system sounds: beep, asterisk, question, etc. in C#

This example shows how to do something simple yet very useful: playing the default system sounds.

Sometimes you may want to make your program beep or make some other sound. It would be nice to just call a Beep method. Visual Basic has one but C# does not.

You could use Console.Beep() but that produces a loud, jarring sound that doesn't fit in well with modern Windows programming.

The solution is to use the System.Media.SystemSounds classes.

  • System.Media.SystemSounds.Asterisk.Play()
  • System.Media.SystemSounds.Beep.Play()
  • System.Media.SystemSounds.Exclamation.Play()
  • System.Media.SystemSounds.Hand.Play()
  • System.Media.SystemSounds.Question.Play()

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.