///
/// 序列化DataTable
///
/// DataTable
///
private static string SerializeDataTableXml(DataTable pDt) {
// 序列化DataTable
StringBuilder sb = new StringBuilder();
XmlWriter writer = XmlWriter.Create(sb);
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));
serializer.Serialize(writer, pDt);
writer.Close();
return sb.ToString();
}
///
/// 反序列化DataTable
///
/// 序列化的DataTable
///
public static DataTable DeserializeDataTable(string pXml) {
StringReader strReader = new StringReader(pXml);
XmlReader xmlReader = XmlReader.Create(strReader);
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));
DataTable dt = serializer.Deserialize(xmlReader) as DataTable;
return dt;
}
沒有留言:
張貼留言