public class Person : IComparable<Person>, IEquatable<Person>
{
[XmlElement(“Name”)]
public string Name
{
get;
set;
}
[XmlElement(“ID”)]
public int ID
{
get;
set;
}
[XmlElement(“Phone”)]
public string Phone
{
get;
set;
}
[XmlElement(“Address”)]
public string Address
{
get;
set;
}
public Person() : this(“”, 0, “”, “”)
{
}
public Person(string name, int id, string phone, string address)
{
this.Name = name;
this.ID = id;
this.Phone = phone;
this.Address = address;
}
public Person(Person p)
{
this.Name = p.Name;
this.ID = p.ID;
this.Phone = p.Phone;
this.Address = p.Address;
}
public virtual void Print()
{
Console.WriteLine(“이름: {0} ID: {1} 전화번호: {2} 주소: {3}”, this.Name, this.ID, this.Phone, this.Address);
}
// System.Object.ToString method override
public override string ToString()
{
// csv file format으로 출력
return string.Format(“{0},{1},{2},{3}”, Name, ID, Phone, Address);
}
// 중간생략…
}
<ArrayOfPerson xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema“>
<Person>
<Name>Park </Name>
<ID>1207</ID>
<Phone> 010-</Phone>
<Address>단국대학교</Address>
</Person>
<Person>
<Name>박똑똑</Name>
<ID>5205</ID>
<Phone>10</Phone>
<Address>단국대</Address>
</Person>
<Person>
<Name>아무개</Name>
<ID>1202</ID>
<Phone>041-550-3418</Phone>
<Address>충남 천안시</Address>
</Person>
<Person>
<Name>홍군</Name>
<ID>1204</ID>
<Phone> 041-550-3490</Phone>
<Address>충남 천안시</Address>
</Person>
<Person>
<Name>김씨</Name>
<ID>5204</ID>
<Phone>11</Phone>
<Address>단국대</Address>
</Person>
</ArrayOfPerson>