title: Adding XML Attribute to a WCF Service
body: <p>I have a class like this,</p>
  
  <pre><code>[DataContract]
  public class FruitCrate
  {
    [XmlAttribute]
    public int NumberOfFruits;
  
    [DataMember(Name = "Cats")]
    public List&lt;Cats2009&gt; Cats;
  }
  
  [DataContract]
  public class Cats2009
  {
      [DataMember]
      public string Name;
  }
  </code></pre>
  
  <p>Now even if there are no Cats in Fruit Crate, I still want it return result as,</p>
  
  <pre><code>&lt;FruitCrate NumberOfFruits="1"&gt;
   &lt;cats MomName="BigBadCat" /&gt;
  &lt;/FruitCrate&gt;
  </code></pre>