+ 2

c#

SoundPlayer a = new SoundPlayer (@“D:\letter\a.wav”); SoundPlayer b = new SoundPlayer (@“D:\letter\b.wav”); SoundPlayer c = new SoundPlayer (@“D:\letter\c.wav”); SoundPlayer d = new SoundPlayer (@“D:\letter\d.wav”); SoundPlayer e = new SoundPlayer (@“D:\letter\e.wav”); String allLetter=null; switch(allLetter) { case”a”: a.Play(); break; case”b”: b.Play(); break; case”c”: c.Play(); break; case”d”: d.Play(); break; case”e”: e.Play(); break; default: break; } This way is very long , how about short form?

10th Dec 2017, 1:45 PM
lee ratana
1 Answer
+ 9
Assuming the variable allLetter represents the audio file name, you can try the following:- var filePath = Path.Combine(@"D:\letter",
quot;{ allLetter }.wav"); var soundPlayer = new SoundPlayer(filePath); soundPlayer.Play(); Hopefully it helps! 😉
10th Dec 2017, 4:11 PM
Zephyr Koo
Zephyr Koo - avatar