deserializing enums

You could declare the enum property as nullable:

public Language? Language { get; set; }


EDIT: ok, I just tried, it doesn't work for attributes... Here's another option: don't serialize/deserialize this property directly, but serialize a string property instead :

[XmlIgnore]
public Language Language { get; set; }

[XmlAttribute("Language")]
public string LanguageAsString
{
    get { return Language.ToString(); }
    set
    {
        if (string.IsNullOrEmpty(value))
        {
            Language = default(Language);
        }
        else
        {
            Language = (Language)Enum.Parse(typeof(Language), value);
        }
    }
}

You can do it this way:

namespace Example
{

   public enum Language
   {
     [XmlEnum("en")]
     English,

     [XmlEnum("de")]
     Deutsch
   }

   public class ExampleClass
   {

      private Language? language;

      [XmlAttribute("Language")]
      public Language Language
      {
         get { return language ?? Example.Language.English; }
         set { language = value; }
      }

      .
      .
      .
   }
}

You probably need to mark up your enumeration, and add a default item that represents Unknown.

For example:

Public Enum EmployeeStatus
   <XmlEnum("")> Unknown = 0
   <XmlEnum("Single")> One = 1
   <XmlEnum("Double")> Two = 2
   <XmlEnum("Triple")> Three = 3
End Enum

For more information, see here.