当前位置:网站首页>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; } }}边栏推荐
- DGraph: 大规模动态图数据集
- mysql三级分销代理关系存储
- Don't turn down, three sentences to clarify the origin of cross domain resource request errors
- n++也不靠谱
- Comprehensive evaluation of modular note taking software: craft, notation, flowus
- 面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
- Backgroundworker usage example
- 敏捷开发/敏捷测试感受
- AI painting minimalist tutorial
- 干货整理!ERP在制造业的发展趋势如何,看这一篇就够了
猜你喜欢

三星量产3纳米产品引台媒关注:能否短期提高投入产出率是与台积电竞争关键

光环效应——谁说头上有光的就算英雄

A data person understands and deepens the domain model

从0到1建设智能灰度数据体系:以vivo游戏中心为例

《预训练周刊》第52期:屏蔽视觉预训练、目标导向对话

How real-time cloud interaction helps the development of education industry

实时云交互如何助力教育行业发展

DGraph: 大规模动态图数据集

【AI系统前沿动态第40期】Hinton:我的深度学习生涯与研究心法;Google辟谣放弃TensorFlow;封神框架正式开源

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
随机推荐
CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021
Alibaba cloud award winning experience: build a highly available system with polardb-x
Meituan Ali's Application Practice on multimodal recall
C#/VB.NET 给PDF文档添加文本/图像水印
Two dimensional code coding theory
诸神黄昏时代的对比学习
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
SQL语言
PostgreSQL 9.1 飞升之路
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
n++也不靠谱
Valentine's Day confession code
WPF双滑块控件以及强制捕获鼠标事件焦点
Etcd 存储,Watch 以及过期机制
使用 NSProxy 实现消息转发
Node の MongoDB 安装
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Simple understanding of binary search
比量子化学方法快六个数量级,一种基于绝热状态的绝热人工神经网络方法,可加速对偶氮苯衍生物及此类分子的模拟
PostgreSQL 9.1 soaring Road