能贴出你客户端赋值代码吗?注意:
private A a= new A();
AA类型为subA,
如果给a的AA赋值,只能赋subA 类型的
也就是这样:
private subA b= new subA();
b.B = "B";
然后是
a.AA = b;你说的问题我写代码测试过了,所以我认为你错就错在赋值的时候了吧。
是不是给AA赋的不是subA类型的了!
private A a= new A();
AA类型为subA,
如果给a的AA赋值,只能赋subA 类型的
也就是这样:
private subA b= new subA();
b.B = "B";
然后是
a.AA = b;你说的问题我写代码测试过了,所以我认为你错就错在赋值的时候了吧。
是不是给AA赋的不是subA类型的了!
解决方案 »
- VS2010中rdlc如何添加参数
- Webbrowser控件,调试时出现当前页面的脚本发生错误(64位的win7 如何打开32位的注册表)
- 用C#如何修改其它软件上面的名称
- 关于TabContorl控件问题.
- 请问如何获取这个验证码
- 筛选字符串string的问题!
- 请教,我把我的.NET代码,放到了空间供应商提供的空间,但是,他们问我,文件夹的权限怎么设置?谁能帮忙??
- 无法输出中文问题,在线
- 求讲解C#一般文件操作的应用!
- 高手帮忙:有没有谁做过什么控件,或是修改IE的内核,使得用浏览器打开邮件(.eml的文件,outlook接收的)时就可以直接显示该邮件的附件
- c#调用c++dll时const char*类型应该怎么对应
- C++ Dll返回虚接口类,C#调用失败
测试代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace WebA
{
public class WebB
{
private string strB; public string StrB
{
get { return strB; }
set { strB = value; }
} private string strValueB; public string StrValueB
{
get { return strValueB; }
set { strValueB = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace WebA
{
public class WebA
{
private WebB _WebB; public WebB WebB
{
get { return _WebB; }
set { _WebB = value; }
}
}
}
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;namespace WebServiceTest
{
/// <summary>
/// Service1 の概要の説明です
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// この Web サービスを、スクリプトから ASP.NET AJAX を使用して呼び出せるようにするには、次の行のコメントを解除します。
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{ [WebMethod]
public string HelloWorld()
{
return "Hello World";
} [WebMethod]
public WebA.WebA GetValue()
{
WebA.WebA webA = new WebA.WebA();
WebA.WebB webB = new WebA.WebB();
webB.StrB = "StrB";
webB.StrValueB = "StrValueB";
webA.WebB = webB; return webA;
}
}
}
客户端: private void btnTest_Click(object sender, EventArgs e)
{
Service1 service = new Service1();
WebA webA = new WebA();
webA.WebB = new WebB(); webA = service.GetValue();
}
{
Service1 service=new Service1();
WebA webA=new WebA();
webA.WebB=new WebB(); webA= service.GetValue();
}
这个改为:
private void btnTest_Click(object sender, EventArgs e)
{
Service1 service = new Service1();
WebA webA = new WebA();
webA = service.GetValue();
}