01.C#转成xml
using System;using System.Collections;using System.Collections.Generic;using System.Xml.Serialization;usin情感小文章g UnityEngine;[Serializable]public class Player{ [XmlAttribute] public int Id { get; t; } [XmlAttribute] public string Name { get; t; } [XmlArray] ability是什么意思public List<int> List { get; t; } }
void InitXml() { Player player=new Player(); player.Id = 100; player.Name = "得到"; player.List=new List<int>(){1,2,3}; FileStream stream=new FileStream(Application.dataPath+"/Players",FileMode.Create,FileAccess.ReadWrite,FileShare.ReadWrite); StreamWriter streamWriter=n青春的逆行ew StreamWriter(食品安全顺口溜stream,Encoding.UTF8); XmlSerializer xml=new XmlSerializer(typeof(Player)); xml.Serialize(stream,player); streamWriter.Clo(); stream.Clo(); }}
结果
<?xml version="1.0"?><Player xm有这样一种声音作文lns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="100" Name="得到"> <List> <int>1</int> <int>2</int> <int>3</int> </List></Player>
本文地址:https://blog.csdn.net/weixin_33950757/article/details/107623616
本文发布于:2023-04-04 00:57:26,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/f9080a458b7f555d16d88cd979ff1ba6.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:02.xml序列化.doc
本文 PDF 下载地址:02.xml序列化.pdf
留言与评论(共有 0 条评论) |