我的C#程序存在问题:
string sound = MyProgram.Properties.Settings.Default.sound;
if (sound == "Bing")
{
Stream str = Resources.bing;
SoundPlayer soundplayer = new SoundPlayer(Resources.bing);
soundplayer.Play();
} else if (sound == "Bong")
{
Stream str = Resources.bong;
SoundPlayer soundplayer = new SoundPlayer(Resources.bong);
soundplayer.Play();
}
所以代码问题是,这是硬编码的 - 我想生成动态声音......
是否可以使用变量?
进行此操作另外:是否可以立即播放声音播放器而无需在新线路中呼叫soundplayer.Play();
?
此致 蒂莫
(PS:我的英语不太好,所以请原谅我的简短问题:D)