using (var stream = new MemoryStream()) { using (var writer = new XmlTextWriter(stream, Encoding.GetEncoding("GB2312"))) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; var ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); serializer.Serialize(writer, demo,ns); } string result= Encoding.GetEncoding("GB2312").GetString(stream.ToArray()); Console.WriteLine(result); }