我们如何从给定函数传递不同的对象。
static public void SerializeToXML(FbTextView p)
{
XmlSerializer serializer = new XmlSerializer(typeof(FbTextView));
TextWriter textWriter = new StreamWriter(@"D:\movie.xml");
serializer.Serialize(textWriter, p);
textWriter.Close();
}
现在的问题是,当我尝试传递两个或更多这样的两个对象时:
static public void SerializeToXML(FbTextView p,FbTextField q)
{
XmlSerializer serializer = new XmlSerializer(typeof(FbTextView));
XmlSerializer Serializer = new XmlSerializer(typeof(FbTextField));
TextWriter textWriter = new StreamWriter(@"D:\movie.xml");
serializer.Serialize(textWriter, p);
textWriter.Close();
}
它抛出错误:未处理 XMLParse 异常。内部异常是:“有一个错误反映类型'FBformBuilder.FbTextField”谢谢!