C# flushing StreamWriter and a MemoryStream
问题 I use the following snippet of code, and I'm unsure whether I need to call the Flush methods (once on StreamWriter , once on MemoryStream ): //converts an xsd object to the corresponding xml string, using the UTF8 encoding public string Serialize(T t) { using (var memoryStream = new MemoryStream()) { var encoding = new UTF8Encoding(false); using (var writer = new StreamWriter(memoryStream, encoding)) { var serializer = new XmlSerializer(typeof (T)); serializer.Serialize(writer, t); writer