请大家看看这段程序,如何在返回值中增加一个属性?
下面的WebService方法返回一个RetObjs类型的对象,它继承了List但增加了一个属性。
public class WebService_ReturnObject : WebService
{
public class RetObj{}
public class RetObjs : List<RetObj>
{
private int _count;
public int RecordCount
{
get { return _count; }
set { _count = value; }
}
}
[WebMethod()]
[XmlInclude(typeof(RetObjs))]
public RetObjs getRetObjs()
{
RetObjs ret = new RetObjs();
ret.RecordCount = 100;
ret.AddRange(new RetObj[] { new RetObj(), new RetObj() });
return ret;
}
}
但我在VS Studio中通过View in Browser执行的结果中没有这个属性,请问各位是什么原因,如何增加上?
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfRetObj xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<RetObj />
<RetObj />
</ArrayOfRetObj>