设置类属性值后创建xml文件 [英] create xml file after setting class properties values

查看:115
本文介绍了设置类属性值后创建xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个班级(姓名=客户)



使用本课程中的不同资产



i可以设置类属性值



我想要做的是创建此类或其实例的XML文件


$设置所有属性值后b $ b ...





怎么做?



先谢谢

i have a class ( name= customer )

using different propertied in this class

i can set class properties value

what i want to do is to create XML file of this class or its instance

after setting all properties value...


how to do this ??

Thanks in Advance

推荐答案

using System;

public class clsPerson
{
  public  string FirstName;
  public  string MI;
  public  string LastName;
}

class class1
{
   static void Main(string[] args)
   {
      clsPerson p=new clsPerson();
      p.FirstName = "Jeff";
      p.MI = "A";
      p.LastName = "Price";
      System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
      x.Serialize(Console.Out, p);
      Console.WriteLine();
      Console.ReadLine();
   }
}


这篇关于设置类属性值后创建xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆