Assigning a default value to a property
<p>I have an xml like so:</p>

<pre><code>&lt;Settings&gt;
  &lt;User default="Programmer"&gt;&lt;/User&gt;
  &lt;Level default="2"&gt;&lt;/Level&gt;
&lt;Settings&gt;
</code></pre>

<p>This is deserialized to an object of type UserSettings:</p>

<pre><code>[Serializable]
[XmlRoot("Settings")]
public class UserSettings
{
    [XmlElement("User")]
    public string User { get; set; }

    [XmlElement("Level")]
    public string Level { get; set; }

}
</code></pre>

<p>The UserSettings object gives whatever the values are there for the tags at runtime.</p>

<p>I want the class to return the default attribute value when either the tag is empty or the tag is absent in the incoming xml.</p>

<p>So if there is an object objUserSettings of type UserSettings then</p>

<p><code>objUserSettings.User</code></p>

<p>should give "Programmer", or whatever is in default attribute value in the xml if the tag User is empty.</p>

<p>Regards.</p>
