xml序列化属性问题,如果你知道,很简单
未处理的“System.InvalidOperationException”类型的异常出现在 system.xml.dll 中
其他信息:生成 XML 文档时出错。
源代码:
using System;
using System.IO ;
using System.Xml ;
using System.Xml.Serialization ;
namespace xmlserlizer
{
public class Employee
{
public string Name;
public string Salary;
private string FullNum;
public string telephonenumber
{
get
{
return FullNum.Substring(9,3);
}
set
{
FullNum="222-7777"+value;
}
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
Employee Employee1=new Employee();
Employee1.Name="th smith";
Employee1.Salary="02000";
Employee1.telephonenumber="213";
XmlSerializer serializer =new XmlSerializer(typeof(Employee));
Stream writer1 = new FileStream("C:\\employee.xml", FileMode.Create);
serializer.Serialize(writer1,Employee1);
}
}
}