Answer the question
In order to leave comments, you need to log in
Is StringWriter inherited from Stream?
XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());
using(StringWriter textWriter = new StringWriter())
{
xmlSerializer.Serialize(textWriter, toSerialize);
return textWriter.ToString();
}
Answer the question
In order to leave comments, you need to log in
The Serialize method is overloaded and, among other things, can take a TextWriter , from which StringWriter is inherited .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question