带事件处理程序的静态函数 [英] Static function with event handler

查看:62
本文介绍了带事件处理程序的静态函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当我在Windows Phone 8中使用  OpenReadCompleted事件创建静态功能时,我收到以下错误。

错误16非静态字段,方法或属性'Demo_Dev.Mainport.downloadclient_OpenReadCompleted(object,System.Net.OpenReadCompletedEventArgs)'

这是我的代码:

 public static void downloadfile()
{
if(App。 downdetails.Count!= 0)
{
App.change = true;
var downloadclient = new WebClient();
downloadclient.OpenReadAsync(new Uri("my url here"));
downloadclient.OpenReadCompleted + = downloadclient_OpenReadCompleted ;
}
}

我在带下划线的区域收到了该错误。


如何解决此问题?


解决方案

您的"downloadclient_OpenReadCompleted"是什么?函数看起来像?


你不需要发布完整的函数,只需要发布定义,类型和参数。



Hi,

when i'm creating a static function with OpenReadCompleted event in windows phone 8, i received the below error.

Error	16	An object reference is required for the non-static field, method, or property 'Demo_Dev.Mainport.downloadclient_OpenReadCompleted(object, System.Net.OpenReadCompletedEventArgs)'

Here is my code :

public static void downloadfile()
        {
            if (App.downdetails.Count!=0)
            {
                   App.change =true;
                   var downloadclient = new WebClient();
                   downloadclient.OpenReadAsync(new Uri("my url here"));
                   downloadclient.OpenReadCompleted +=downloadclient_OpenReadCompleted;
            }
        }

i received that error on the underlined area.

How to resolve this issue?

解决方案

What does your "downloadclient_OpenReadCompleted" function look like?

You don't need to post the full function, just the definition, type, and arguments.


这篇关于带事件处理程序的静态函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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