将变量值传递给静态WebMethod [英] Pass a variable value into a static WebMethod

查看:88
本文介绍了将变量值传递给静态WebMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将变量值传递给静态WebMethod,但因错误而失败:

I want to pass a variable value into a static WebMethod, but failed with the error: "

Error   37  An object reference is required for the non-static field, method, or property 



应该用什么方法来解决这个问题?提前谢谢。


What approach should be used to solve this problem? Thanks in advance.

推荐答案

string s = "sss";
        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod(UseHttpGet = true)]
        public static string[][] GetData2(string route, string mA, string mB)  {
            string routeInput = s; 
        ... }





s需要是静态参考,更改为:





s needs to be a static reference, change to:

static string s = "sss";

...


这篇关于将变量值传递给静态WebMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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