public string Serialize<T>(T serializeClass)
{
string xmlString = string.Empty;
try
{
if (serializeClass != null)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
StringBuilder xmlStringBuilder = new StringBuilder();
XmlWriterSettings setting = new XmlWriterSettings() { Encoding = Encoding.UTF8};
using (XmlWriter writer = XmlWriter.Create(xmlStringBuilder, setting))
{
serializer.Serialize(writer, serializeClass);
xmlString = xmlStringBuilder.ToString();
}
}
}
catch (Exception ex)
{
xmlString = string.Empty;
}
return xmlString;
}