/// <summary>
/// Serialize Class Object to XML
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static string XmlSerialize<T>(T obj)
{
XmlSerializer ser = new XmlSerializer(typeof(T));
StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);
ser.Serialize(tw, obj);
string result = sw.ToString();
return result;
}
/// Serialize Class Object to XML
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static string XmlSerialize<T>(T obj)
{
XmlSerializer ser = new XmlSerializer(typeof(T));
StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);
ser.Serialize(tw, obj);
string result = sw.ToString();
return result;
}
No comments:
Post a Comment