C#播放声音与C#code的一行 [英] c# play sound with one line of c# code
本文介绍了C#播放声音与C#code的一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我玩其他一些codeRS游戏。你得到你想要写的C#1 ONELINE和尽可能多的XAML行。
任何人都知道如何在一行分号之前播放声音;
这是接近我可以得到到目前为止
声音播放simpleSound =新的SoundPlayer(@C:\\媒体\\ pacman.wav);
simpleSound.Play();
编辑:试图Blorgbeard的code,但声音是不是在玩出于某种原因
如果(Listbox.SelectedItem.ToString()==2好2 B真)
{
尝试
{
(新声音播放(@/项目;组件/声音/ pacman.wav))播放()。
}
赶上(异常前)
{
Console.Error.WriteLine(ex.Message);
}}
解决方案
不需要一个变量:
(新的SoundPlayer(@C:\\媒体\\ pacman.wav))播放();
I'm playing a game with some others coders. You get to write one oneline of C# and as many xaml lines as you want.
Anyone know how to play a sound in one line before the semi-colon;
This is as close as I can get so far
SoundPlayer simpleSound = new SoundPlayer(@"c:\Media\pacman.wav");
simpleSound.Play();
Edit: tried Blorgbeard's code, but sound isn't playing for some reason
if (Listbox.SelectedItem.ToString() == "2 Good 2 B True")
{
try
{
(new SoundPlayer(@"/Project;component/sounds/pacman.wav")).Play();
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
解决方案
No need for a variable:
(new SoundPlayer(@"c:\Media\pacman.wav")).Play();
这篇关于C#播放声音与C#code的一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文