*实体类
namespaceDataInterface.Model
{
publicclassMetercs
{
publicstringMname{get;set;}
publicstringTid{get;set;}
publicstringTname{get;set;}
publicstringTzdxh{get;set;}
}
publicclassMetercsList
{
publicList<Metercs>getMetercs{get;set;}
}
}
*转换操作
List<Metercs>Reterminals=newList<Metercs>();
foreach(varretinmeters)
{
Reterminals.Add(newMetercs(){Mname=ret.Mname,Tid=ret.Tid,Tname=ret.Tname,Tzdxh=ret.Tzdxh});
}
MetercsListTerminallist=newMetercsList();
Terminallist.getMetercs=Reterminals;
reStr=newJavaScriptSerializer().Serialize(Terminallist);
转载于:https://blog.51cto.com/benbird/1300122