DataContractSerializer - how can I output the xml to a string (as opposed to a file)
I had a quick question regarding the datacontractserializer. Maybe it's more of a stream question. I found a piece of code that writes the xml to a filestream. I basically don't want the file and just need the string output. public static string DataContractSerializeObject<T>(T objectToSerialize) { var fs = new FileStream("test.xml", FileMode.OpenOrCreate); var serializer = new DataContractSerializer(typeof(T)); serializer.WriteObject(fs, objectToSerialize); fs.Close(); return fs.ToString(); } fs.ToString() is obviously not what I'm looking for. What stream or writer etc, can I use just to