要序列化的對象的類:
[Serializable]
public class Person
{
private
string name;
public
string Name
{
get
{
return name;
}
set
{
name=value;
}
}
public
string Sex;
public
int Age=31;
public Course[] Courses;
public Person( )
{
}
public Person(
string Name )
{
name=Name;
Sex="男";
}
}
[Serializable]
public class Course
{
public
string Name;
[XMLIgnore]
public
string Description;
public Course( )
{
}
public Course(
string name,
string description )
{
Name=name;
Description=description;
}
}