-1

I would like to play a different sound based on the value of a variable. I could do independent IF statements but I'd like to do it in an array. I have a global

SystemSound[] sound_array=new SystemSound[5];

and in form.load I do

sound_array[0] = SystemSounds.Beep;
sound_array[1] = SystemSounds.Asterisk;
sound_array[2] = SystemSounds.Exclamation;
sound_array[3] = SystemSounds.Hand;
sound_array[4] = SystemSounds.Question;

then in the main code I have

SystemSounds.sound_array[i].Play();

if I do SystemSounds.beep.Play();

it works fine, I just can't figure out how to do it in an array. I get Error 1 'System.Media.SystemSounds' does not contain a definition for 'sound_array' Thanks

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Ringo Davis
  • 43
  • 1
  • 7

1 Answers1

1

Since you have

SystemSound[] sound_array=new SystemSound[5];

sound_array is a local variable. The correct way to use it is sound_array instead of SystemSounds.sound_array:

sound_array[i].Play();
Michael Kim
  • 689
  • 5
  • 20