title: XmlSerializer and nullable attributes
body: <p>I have a class with numerous Nullable&lt;T&gt; properties which I want to be serializable to XML as attributes. This is apparently a no-no as they are considered 'complex types'. So, instead I implement the *Specified pattern, where I create an addition *Value and *Specified property as follows:</p>
  
  <pre>
  [XmlIgnore]
  public int? Age
  {
      get { return this.age; }
      set { this.age = value; }
  }
  
  [XmlAttribute("Age")]
  public int AgeValue
  {
      get { return this.age.Value; }
      set { this.age = value; }
  }
  
  [XmlIgnore]
  public bool AgeValueSpecified
  {
      get { return this.age.HasValue; }
  }
  </pre>
  
  <p>Which works fine - if the 'Age' property has a value, it is serialized as an attribute. If it doesn't have a value, it isn't serialized. </p>
  
  <p>The problem is that, as I mentioned, a have a lot of Nullable-s in my class and this pattern is just making things messy and unmanageable. </p>
  
  <p>I'm hoping there is a way to make Nullable more XmlSerializer friendly. Or, failing that, a way to create a Nullable replacement which is. </p>
  
  <p>Does anyone have any ideas how I could do this? </p>
  
  <p>Thanks.</p>