public class Container : XmlElementGenerator
{
public string projectcode { get; set; }
public string projectname { get; set; }
public string projectleader { get; set; }
public string barcode { get; set; }
public string sampleartid { get; set; }
public string sampledescription { get; set; }
public string remark { get; set; }
public DateTime samplingdate { get; set; }
public int samplenumber { get; set; }
public XmlElement GenerateXMLElement(XmlDocument xmlDocument)
{
Type containerGenerator = typeof(Container);
XmlElement container = ElementChildrenGenerator(xmlDocument, "container");
foreach (PropertyInfo prop in containerGenerator.GetProperties())
{
container.AppendChild(ElementChildrenGenerator(xmlDocument, prop.Name, prop.GetValue(this).ToString()));
}
return container;
}
}
此处出现错误prop.GetValue(this)-“ System.NullReferenceException:对象引用未设置为对象的实例”。为什么我不能使用“ this”来访问对象?我不想再添加一个参数。请帮助
波斯汪
相关分类