我的应用程序中有一个"Gesture"类列表:
List<Gesture> gestures = new List<Gesture>();
Run Code Online (Sandbox Code Playgroud)
这些手势类非常简单:
public class Gesture
{
public String Name { get; set; }
public List<Point> Points { get; set; }
public List<Point> TransformedPoints { get; set; }
public Gesture(List<Point> Points, String Name)
{
this.Points = new List<Point>(Points);
this.Name = Name;
}
}
Run Code Online (Sandbox Code Playgroud)
我想允许用户将"手势"的当前状态保存到文件中,并且还能够加载包含手势数据的文件.
在C#中执行此操作的标准方法是什么?
我应该使用序列化吗?我应该自己编写一个类来处理这个XML文件的编写/读取吗?还有其他方法吗?
看一下.net中的XmlSerializer类型和XmlSerialization
这里......找到了一个可以满足您需求的例子 http://www.switchonthecode.com/tutorials/csharp-tutorial-xml-serialization