Serialize Object To String


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public string SerializeToString<T>(T obj)
  2. {
  3. StringWriter sw = new StringWriter();
  4.  
  5. XmlSerializer serializer = new XmlSerializer(typeof(T));
  6. serializer.Serialize(sw, obj);
  7.  
  8. return sw.ToString();
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.