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; }}此處出現(xiàn)錯誤prop.GetValue(this)-“ System.NullReferenceException:對象引用未設(shè)置為對象的實例”。為什么我不能使用“ this”來訪問對象?我不想再添加一個參數(shù)。請幫助
- 2 回答
- 0 關(guān)注
- 155 瀏覽
添加回答
舉報
0/150
提交
取消