コード例 #1
0
        public void Deserialize()
        {
            var personAsJson = File.ReadAllText("Person.json");

            var person = JsonConvert.DeserializeObject <Person>(personAsJson);

            UsefulFunctions.WritePersonToConsole(person);
        }
コード例 #2
0
        public void Deserialize()
        {
            var serializer = new XmlSerializer(typeof(Person));

            var person = (Person)serializer.Deserialize(File.OpenRead("Person.xml"));

            UsefulFunctions.WritePersonToConsole(person);
        }
コード例 #3
0
        public void Serialize()
        {
            var person = UsefulFunctions.CreateAPerson();

            var personAsJson = JsonConvert.SerializeObject(person, Formatting.Indented);

            Console.Out.WriteLine(personAsJson);
        }
コード例 #4
0
        public void Serialize()
        {
            var person = UsefulFunctions.CreateAPerson();

            var serializer = new XmlSerializer(typeof(Person));

            var writer = new StringWriter();

            serializer.Serialize(writer, person);
            Console.Out.WriteLine(writer.ToString());
        }