Reputation: 79
I'm trying to deserialize an XML (it's working so far). The XML reads in everything as strings.
When it goes to populate the property ID, I want to convert it to a GUID from the string. But I can't seem to get this work.
Thanks.
public class Feature
{
[XmlAttribute]
public string ID
{
set
{
ID = new Guid(ID);
}
}
XML:
<Features>
<Feature ID="8581a8a7-cf16-4770-ac54-260265ddb0b2" FeatureName="SharePoint Server Enterprise Site Collection features" />
</Features>
Upvotes: 0
Views: 63
Reputation: 17233
Your code doesnt compile, but regardless - why don't you just change the property type from string
to Guid
? the conversion will happen automatically when you deserialize. Try it:
public class Feature
{
[XmlAttribute]
public Guid ID { get; set; }
}
Upvotes: 1