错误:无法隐式转换类型... [英] Error: Cannot implicitly convert type...

查看:85
本文介绍了错误:无法隐式转换类型...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Windows Mobile 6中制作了一个简单的GUI游戏应用程序.我正在尝试为我的移动应用程序添加背景声音,但是它无法正常工作,但是我可以为Windows窗体应用程序简单地添加背景声音,但是在移动应用程序中代码是不工作.那么在这种情况下有人可以帮助我吗?

我已经在移动应用形式load()中使用了以下代码:

I have just made simple GUI game application in windows mobile 6. I am trying to add background sound for my mobile application but its not working however I can simply add background sound for windows form application but incase of mobile application that code is not working. So can anyone help me in this case?

I have used following code in mobile applaition form load():

private System.Media.SoundPlayer mediaplayer = new   System.Media.SoundPlayer();	 
mediaplayer.Stream = Properties.Resources.mysoundfilename;
mediaplayer.PlayLooping();


并生成如下错误:
无法将类型"byte []"隐式转换为"System.IO.Stream"
有人可以帮我解决这个问题吗?


and it generates the error like this:
Cannot implicitly convert type ''byte[]'' to ''System.IO.Stream''
Can anyone help me out to solve this issue?

推荐答案

此链接提供了一个可以帮助您的示例:
http://msdn.microsoft.com/en-us/library/3w5b27z4.aspx [ ^ ]

祝你好运!
This link provides an example that should help you out:
http://msdn.microsoft.com/en-us/library/3w5b27z4.aspx[^]

Good luck!


错误本身是不言而喻的:
无法将类型"byte []"隐式转换为"System.IO.Stream"

MediaPlayer在这里期望分配时有一个System.IO.Stream类对象. ``Properties.Resources.mysoundfilename''看起来不像一个.确保分配的对象类型正确且类型相同.
mediaplayer.Stream = Properties.Resources.mysoundfilename;
Error itself is self explanatory:
Cannot implicitly convert type ''byte[]'' to ''System.IO.Stream''

MediaPlayer here is expecting a System.IO.Stream kinda object while assignment. ''Properties.Resources.mysoundfilename'' does not look like one. Make sure the type of object assigned is correct and of same type.
mediaplayer.Stream = Properties.Resources.mysoundfilename;


这篇关于错误:无法隐式转换类型...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆