我拥有XML,如下所示。将XML中的键值对反序列化为c#对象
<Device-array>
<Device>
<id>8</id>
<properties>
<PropKeyValuePair>...</PropKeyValuePair>
<PropKeyValuePair>...</PropKeyValuePair>
</properties>
</Device>
<Device>...</Device>
<Device>...</Device>
</Device-array>
我打算将其反序列化为C#对象,以便它会更快。我只需要id字段。但我明白,类需要有一个(属性)数组。但是,我如何表达关键价值对?
[Serializable()]
public class SLVGeoZone
{
[XmlElement("id")]
public string id { get; set; }
//Arraylist of key value pairs here ?
}
需要suggetions。
如果您只需要ID,你为什么加入keyvaluepairs到类?我非常确定,当您反序列化时,您不会引用的标记将被忽略。 – Blorgbeard