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>

Kiran MohantyRank #821 · 2.8K reputationPosted Mar 10, 2021, 4:07 AM EST
Hakan AxheimRank #8,316 · 224 reputationPosted Mar 14, 2021, 2:26 PM EDT
The class Images shall have