zoukankan      html  css  js  c++  java
  • 把类序列化为xml字符串

    把类序列化为xml字符串

    using System; using System.Text; using System.XML; using System.IO; 

    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());

                StringBuilder sb 
    = new StringBuilder();
                StringWriter sw 
    = new StringWriter(sb);
               
                x.Serialize(sw, p);

                Console.Write(sb.ToString());
                Console.ReadLine();
            }
        }

  • 相关阅读:
    P2161 [SHOI2009]会场预约
    struts jar包
    struts
    HTML 简述
    JSP入门 分页
    JSP入门 生命周期
    JSP入门 el表达式
    JSP入门 导出文件
    JSP入门 文件上传
    自动增量字段重新从1开始的方法
  • 原文地址:https://www.cnblogs.com/wenming205/p/1557988.html
Copyright © 2011-2022 走看看