📄 client.cs
字号:
using System;
using System.Text;
using System.IO;
using System.Xml.Serialization;
namespace XmlSerializationConfig
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Client
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ReadPeopleFromConfiguration();
// wait to exit
Console.ReadLine();
}
/// <summary>
/// Reads the list of people from the configuration file.
/// </summary>
static void ReadPeopleFromConfiguration()
{
Person[] personArr = PersonFactory.GetProple();
foreach(Person p in personArr)
{
Console.WriteLine("{0} {1}",p.Firstname,p.Lastname);
}
}
/// <summary>
/// Simple example to demonstrate what an object would
/// look like in XML format once it has been serialized.
/// </summary>
static void SimpleSerializationExample()
{
// create an instance of the class
Person p = new Person();
p.Firstname = "Brady";
p.Lastname = "Gaster";
// serialize it
XmlSerializer ser = new XmlSerializer(typeof(Person));
StringWriter sw = new StringWriter();
ser.Serialize(sw,p);
// show the xml
Console.WriteLine(sw.ToString());
sw.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -