Hi,
I want to deserialize an XML string into two classes. My main class is called Images se below and that class shall reference to another class called Image. As you can see I want a List of Image connected to the Images class. When I deserialize my XML string the List will not be assigned to the values in my XML string. I don't know why. Maybe someone can help me with this problem?
- namespace DataContractSample.DataContract.Model
- {
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- [DataContract(Name="objects", Namespace = "", IsReference = true)]
- [KnownType(typeof(IList
))] - public class Images
- {
- [DataMember(Name = "object")]
- public IList
ImageList { get; set; } - }
- }
- namespace DataContractSample.DataContract.Model
- {
- using System;
- using System.Runtime.Serialization;
- [DataContract(Name = "object", Namespace = "")]
- public class Image
- {
- [DataMember(Name = "id")]
- public Guid Id { get; set; }
- }
- }
This is my XML string:
- <objects>
- <object>
- <id>CF7E7B22-1D3A-4CFE-91F9-F8C5C2DB4069id>
- object>
- <object>
- <id>CF7E7B22-1D3A-4CFE-91F9-F8C5C2DB4070id>
- object>
- objects>
Hakan AxheimPosted Mar 14, 2021, 6:26 PM
The class Images shall have
Kiran MohantyPosted Mar 10, 2021, 9:07 AM