当前位置:网站首页>Introduction to XML II
Introduction to XML II
2022-07-04 13:41:00 【Hua Weiyun】
Xml Basics 02
Several serialization methods and deserialization :
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace day29test03{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { // Declare object mode Person person = new Person(); person.Age = 20; person.Name = "qew"; person.Height = 1777; // Sequence mode Basic xml serialize System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Person)); System.IO.TextWriter yw = new System.IO.StreamWriter(@"F:\.net Study \test\xmldeemp1\1.xml"); xmlSerializer.Serialize(yw, person); yw.Dispose(); // Binary serialization Strong commonality System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); //soap serialize It is used to transmit data on the network //SoapSeriailzation // Output the serialized stream System.IO.MemoryStream ms = new System.IO.MemoryStream(); xmlSerializer.Serialize(ms, person); // Buffered byte[] ns = ms.GetBuffer(); String str = System.Text.Encoding.UTF8.GetString(ns); MessageBox.Show(str); // Unbuffered //byte[] vs = ms.ToArray(); } private void button2_Click(object sender, EventArgs e) { // Deserialization System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Person)); System.IO.TextReader tr = new System.IO.StreamReader(@"F:\.net Study \test\xmldeemp1\1.xml"); Person p = (Person)xmlSerializer.Deserialize(tr); //xmlSerializer.Deserialize(); } } [System.Xml.Serialization.XmlRoot("mtxml", Namespace="www.nb.com")] public class Person { private String name; private int age; private double height; public string Name { get => name; set => name = value; } public int Age { get => age; set => age = value; } public double Height { get => height; set => height = value; } }}
边栏推荐
猜你喜欢
Reinforcement learning - learning notes 1 | basic concepts
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Etcd storage, watch and expiration mechanism
PostgreSQL 9.1 飞升之路
CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021
A taste of node JS (V), detailed explanation of express module
2022年中国移动阅读市场年度综合分析
求解:在oracle中如何用一条语句用delete删除两个表中jack的信息
HAProxy高可用解决方案
8 expansion sub packages! Recbole launches 2.0!
随机推荐
上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
AI painting minimalist tutorial
二分查找的简单理解
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
WPF double slider control and forced capture of mouse event focus
Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
A data person understands and deepens the domain model
Comprehensive evaluation of modular note taking software: craft, notation, flowus
jsonp
7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多
Etcd 存储,Watch 以及过期机制
七、软件包管理
Commvault 和 Oracle 合作,在 Oracle 云上提供 Metallic数据管理即服务
Reading cognitive Awakening
Use fail2ban to prevent password attempts
Node の MongoDB 安装
面试官:Redis 过期删除策略和内存淘汰策略有什么区别?
Samsung's mass production of 3nm products has attracted the attention of Taiwan media: whether it can improve the input-output rate in the short term is the key to compete with TSMC
Definition of cognition
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing