Class to XML

 public static string ToXml<T>(this T value) where T : class
        {
            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
                using (StringWriter stringWriter = new StringWriter())
                {
                    xmlSerializer.Serialize(stringWriter, value);
                    return stringWriter.ToString();
                }
            }
            catch (Exception)
            {

            }
            return null;
        }
Example:
none

Description

Parse Class to XML

Details

Double click on the code to select all.

 

;