当前位置:网站首页>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; } }}边栏推荐
- n++也不靠谱
- Dry goods sorting! How about the development trend of ERP in the manufacturing industry? It's enough to read this article
- A taste of node JS (V), detailed explanation of express module
- 面试官:Redis 过期删除策略和内存淘汰策略有什么区别?
- Meituan Ali's Application Practice on multimodal recall
- Detailed explanation of mt4api documentary and foreign exchange API documentary interfaces
- 上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
- PostgreSQL 9.1 飞升之路
- 8 expansion sub packages! Recbole launches 2.0!
- It is six orders of magnitude faster than the quantum chemical method. An adiabatic artificial neural network method based on adiabatic state can accelerate the simulation of dual nitrogen benzene der
猜你喜欢

"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue

Is the outdoor LED screen waterproof?

Talk about the design and implementation logic of payment process

C#/VB.NET 给PDF文档添加文本/图像水印

PostgreSQL 9.1 飞升之路

PostgreSQL 9.1 soaring Road

Golang sets the small details of goproxy proxy proxy, which is applicable to go module download timeout and Alibaba cloud image go module download timeout

干货整理!ERP在制造业的发展趋势如何,看这一篇就够了

CANN算子:利用迭代器高效实现Tensor数据切割分块处理

比量子化学方法快六个数量级,一种基于绝热状态的绝热人工神经网络方法,可加速对偶氮苯衍生物及此类分子的模拟
随机推荐
Efficient! Build FTP working environment with virtual users
诸神黄昏时代的对比学习
The old-fashioned synchronized lock optimization will make it clear to you at once!
使用Scrcpy投屏
Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
从0到1建设智能灰度数据体系:以vivo游戏中心为例
mysql三级分销代理关系存储
XML入门三
Etcd 存储,Watch 以及过期机制
jsonp
Agile development / agile testing experience
Implementation mode and technical principle of MT4 cross platform merchandising system (API merchandising, EA merchandising, nj4x Merchandising)
C#/VB. Net to add text / image watermarks to PDF documents
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
C#基础补充
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
"Tips" to slim down Seurat objects
Master the use of auto analyze in data warehouse
8个扩展子包!RecBole推出2.0!
Reading cognitive Awakening