我尝试将我的对象的属性写下来到xml文件......但它不起作用。
方法:
public void Save(string fileName)
{
var stream = new FileStream(fileName, FileMode.Create);
new XmlSerializer(typeof(Character)).Serialize(stream, this);
stream.Close();
}
主要:
class Program
{
static void Main(string[] args)
{
var char1 = new Character();
char1.setDexterity(20);
char1.Save("CharData.xml");
}
}
我也试过了char1.save(@"C:\Users\Avell B155\Desktop\CharData.xml");