当使用WebMethod返回自定义对象时,生成本地代理类时,会抹去你定义的Private成员和方法。
你只有将对象进行二进制序列化再反序列化。
http://community.csdn.net/Expert/topic/3929/3929625.xml?temp=.1452753
public static byte[] BinarySerialize(object obj)
{
BinaryFormatter bf = new BinaryFormatter();
using(MemoryStream ms = new MemoryStream())
{
bf.Serialize(ms, obj);
ms.Close();
return ms.ToArray();
}
}
public static object BinaryDeserialize(byte[] bytes)
{
BinaryFormatter bf = new BinaryFormatter();
object obj;
using(MemoryStream ms = new MemoryStream(bytes))
{
obj = bf.Deserialize(ms);
ms.Close();
}
return obj;
}