另一种方法是创建一个具有您想要的两个返回值的自定义数据类型:
[Serializable]
public sealed class MyData
{
public string Data { get; set; }
public string Data1 { get; set; }
}
...
[WebMethod(EnableSession = true)]
public MyData testing(string testId)
{
string data = string.Empty;
string data1 = string.Empty;
List<test1> datalist1 = new List<test1>();
List<test> datalist = new List<test>();
//coding
data = jsonSerialize.Serialize(datalist1);
data1 = jsonSerialize.Serialize(datalist);
return new MyData { Data = data, Data1 = data1 };
}
或者
[Serializable]
public sealed class MyData
{
public List<test> Data { get; set; }
public List<test1> Data1 { get; set; }
}
...
[WebMethod(EnableSession = true)]
public string testing(string testId)
{
MyData data = new MyData();
string alldata = string.Empty;
List<test1> datalist1 = new List<test1>();
List<test> datalist = new List<test>();
//coding
data.Data = datalist1;
data.Data1 = datalist;
alldata = jsonSerialize.Serialize(data);
return alldata;
}