在youtube上关注教程后,仍然有错误:
XmlElement'在此声明类型上无效。它只对有效 'property,indexer,field,param,return'声明
代码示例:
[XmlRoot("cmdCommunicate")]
public class CMDCommunicate
{
[XmlElement("login")]
public Login loginData { get; set; }
[XmlElement("injectionType")]
public InjectionType injectionType { get; set; }
}
这里我收到错误
[XmlElement("login")]
public class Login
{
[XmlElement("server")]
public string Server{ get; set; }
}
答案 0 :(得分:2)
通过将[XmlElement("login")]
更改为:c [XmlRoot("login")]