I’m making an Alphabet program where if you enter “A B C” and press a button it would play the sound file for A and then the sound file for B and so on.
Currently I use a queue to store the all the uri that link to the sound files like so
switch (word)
{
case "A":
uriQueue.Enqueue(new Uri("Assets/A.wav", UriKind.Relative));
break;
case "B":
uriQueue.Enqueue(new Uri("Assets/B.wav", UriKind.Relative));
break;
case "C":
...
Is there a better way to do this with a large number of sound files beside using a really long switch statement and manually type in each case?
If your
wordis always guaranteed to match your file name, you can drop the entireswitchblock and replace it withOtherwise, you can use a
that you populate with the letters as keys and the paths as values and then use