有人知道为什么这不起作用?我的错误在这里:new XmlSerializer(typeof(classDTO))
namespace Class.DTOS
{
public class classDTO
{
public int classId { get; set; }
public string className { get; set; }
public List<Student> students{ get; set; }
}
// Student is a class with properties of type string and int
public class PathFile
{
public string Path { get; set; }
}
}
其他类别
public void myMethod(classDTO classDto, string path, Stream stream)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(classDTO)); //Here is my error
//....
}
到目前为止,代码中一直存在单词class
本身,您可以将其用作变量名。
public void myMethod(classDTO **class**, string path, Stream stream)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(classDTO)); //Here is my error
//....
}
您不能用原始类型(int,string,bool)或类声明变量。使用其他变量名。