Пример #1
0
        public static void JSONDeserializationDemo()
        {
            string json = "{ \"Name\":\"Subham\",\"Description\":\"Welcome to subham's json\"}";

            BlogSites bsObj2 = JsonConvert.DeserializeObject <BlogSites>(json);

            Console.WriteLine(bsObj2.Name + "\n" + bsObj2.Description);
        }
Пример #2
0
        public static void XmlDeSerializedemo()
        {
            string path = @"C:\Users\user\source\repos\fileIODemoLive\xmlser.txt";

            XmlSerializer xmlser     = new XmlSerializer(typeof(BlogSites));
            FileStream    fileStream = new FileStream(path, FileMode.Open);
            BlogSites     blogSites  = (BlogSites)xmlser.Deserialize(fileStream);

            Console.WriteLine(blogSites.Name + "\n" + blogSites.Description);
            fileStream.Close();
        }
Пример #3
0
        public static void JSONSerializationDemo()
        {
            BlogSites bsObj = new BlogSites()
            {
                Name        = "Subham",
                Description = "Welcome to subham's json"
            };

            string jsonData = JsonConvert.SerializeObject(bsObj);

            Console.WriteLine(jsonData);
        }
Пример #4
0
        public static void XmlSerializedemo()
        {
            string path = @"C:\Users\user\source\repos\fileIODemoLive\xmlser.txt";

            XmlSerializer xmlser     = new XmlSerializer(typeof(BlogSites));
            FileStream    fileStream = new FileStream(path, FileMode.Create);
            BlogSites     blogSites  = new BlogSites()
            {
                Name        = "Subham",
                Description = "Welcome to subham's json"
            };

            xmlser.Serialize(fileStream, blogSites);
            fileStream.Close();
        }