zoukankan      html  css  js  c++  java
  • C#笔记 通用文件的读取之二——XML文件的读取与写入

          在设计程序的时候,对于一些变化性较强的数据,可以保存在XML文件中,以方便用户修改。尤其是对于一些软硬件的配置文件,很多都选择了用XML文件来存取。XML文件简单易用,而且可以在任何应用程序中读写数据,所以它是一种重要的通用文件。下面的例子简单演示了XML文件的创建、读取和写入。
    XmlProcess类中的Using指令
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Xml;

    XmlProcess类
    Code

    读取出的数据仍然缓冲在泛型类List中,数据记录保存在Student类的实例中:
    Student类:
     class Student
        
    {
            
    public int 学号 getset; }
            
    public string 姓名 getset; }
            
    public int 成绩 getset; }
        }

    XML文件的内容:
    Code
    该示例演示的是创建XML文件并在其中手动插入数据。
    如果XML文件已经存在,则可以直接对其进行读取及各种其他操作,具体操作请参见其他博友的博客内容。


  • 相关阅读:
    Redis "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk"问题的解决
    素描
    python 标准库
    Python内置函数filter, map, reduce
    Python的lambda表达式
    python中super关键字的用法
    python一个注意的地方
    python中self,cls
    python中的实例方法、静态方法、类方法、类变量和实例变量
    python模块及包的导入
  • 原文地址:https://www.cnblogs.com/gb2013/p/1577855.html
Copyright © 2011-2022 走看看