标签:serialize typeof name mod ++ 引用 bytes ado set
string json="[{"ID":"1","Name":"哈哈1号","Age":"1"},{"ID":"2","Name":"哈哈2号","Age":"2"},{"ID":"3","Name":"哈哈3号","Age":"3"}]"
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<Model.hello>));//这里需引用using System.Runtime.Serialization.Json; 如果点不出json先添加引用 System.Runtime.Serialization
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json);
List<Model.hello> list = (List<Model.hello>)ser.ReadObject(ms);
for (int i = 0; i < list.Count; i++)
{
hellobll.Add(list[i]);//添加到数据库的方法
}
实体类
public class hello
{
public int ID{get;set;}
public string Name{get;set;}
public string Age{get;set;}
}
标签:serialize typeof name mod ++ 引用 bytes ado set
原文地址:http://www.cnblogs.com/Beata-hu/p/6443528.html