Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Testing DataContractSerializer in .Net 4.5.1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.IO;
using System.Xml;
namespace DCSerializerTest
public class KeywordFunctionMap
public Dictionary<string, string> Map { get; set; }
public KeywordFunctionMap()
Map = new Dictionary<string, string>();
class Program
static void Main(string[] args)
var serializer = new DataContractSerializer(typeof(KeywordFunctionMap));
string xmlString;
var obj = new KeywordFunctionMap();
obj.Map.Add("1", "one");
using (var sw = new StringWriter())
using (var writer = new XmlTextWriter(sw))
writer.Formatting = Formatting.Indented;
serializer.WriteObject(writer, obj);
xmlString = sw.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment