I have an asp.net app with c# code behind. Trying to serialize to xml using a class. However getting the error:
cannot implicitly convert Cannot convert type system.collection.generic.list
This line occurs at:
CourtDocumentEvent = new List<DocumentEventCourtDocumentEvent>
.CS file code :
AddOdyDocToWorkflowRequest AddOdyDocToWorkflowRequest = new AddOdyDocToWorkflowRequest()
{
CaseDocument = new List<CaseDocument>()
{
new CaseDocument()
{
CaseAugmentation = new List<CaseAugmentation>(){
new CaseAugmentation(){
DocumentEvent = new List<DocumentEvent>()
{
new DocumentEvent()
{
CourtDocumentEvent = new List<DocumentEventCourtDocumentEvent>()
{
new DocumentEventCourtDocumentEvent()
{
DocumentData = CaseNumberTextBox.Text+ "," + DocumentCode
}
}
}
}
}
}
}
}
};
This code will will convert your object to XML
public static string ConvertToXml(object obj)
{
StringWriter result = new StringWriter(new StringBuilder());
try
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
serializer.Serialize(result, obj);
return result.ToString();
}
catch (Exception ex)
{
return result.ToString();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.