public static String ObjectToString(Object obj) { try { using (Utf8StringWriter writer = new Utf8StringWriter()) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); serializer.Serialize(writer, obj); return writer.ToString(); } } catch (Exception) { return ""; } }