c# XML序列化与反序列化
原先一直用BinaryFormatter来序列化挺好,可是最近发现在WinCE下是没有办法进行BinaryFormatter操作,很不爽,只能改成了BinaryWriter和BinaryReader来读写,突然想到能不能用XML来序列化?于是在网上查了些资料便写了些实践性代码,做些记录,避免以后忘记。
序列化对象
public class People
{
[XmlAttribute("NAME")]
public string Name
{ set; get; }
[XmlAttribute("AGE")]
public int Age
{ set; get; }
}
[XmlRoot("Root")]
public class Student : People
{
[XmlElement("CLASS")]
public string Class
{ set; get; }
[XmlElement("NUMBER")]
public int Number
{ set; get; }
}
void Main(string[] args)
{
Student stu = new Student()
{
Age = 10,
Class = "Class One",
Name = "Tom",
Number = 1
};
XmlSerializer ser = new Xml
相关文档:
示例演示了用C#操作MySQL的方法,提供了三个可重用的类MySqlDBUtil,MySqlPageUtil,Page。
本示例由 C#操作Access数据库的简单例子(http://www.albertsong.com/read-56.html)修改而来。
1.首先下载MySQL数据库的.NET驱动
http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-5.0.8.1-noinstall.zip/ ......
<Language from="SQL" To="C#">
<Type from="bigint" To="long" />
<Type from="binary" To="object" />
<Type from="bit" To="bool" />
<Type from="char" To="string" />
<Type from="datetime" To="DateTime" ......
/// <summary>
/// 读取数据集并加入缓存
/// sea 2009-12-11
/// </summary>
&nb ......
XML Schema annotation 元素
定义和用法
annotation 元素是一个顶层元素,规定 schema 的注释。
注释:可以包含 appinfo 元素(由应用程序使用的信息)和 documentation 元素(由用户读取或使用的注释或文本)。
元素信息
项目
说明
出现次数
在父元素中一次。
......
XML Schema union 元素
定义和用法
union 元素定义多个 simpleType 定义的集合。
元素信息
出现次数
一次
父元素
simpleType
内容
annotation、simpleType
语法
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType ......