title: Hide datamember from client but still serialize?
body: <p>Is it possible to hide a class' data member from client applications but still serialize with XmlSerializer?</p>
  
  <p>The context is that I'm getting an address in pieces but need to concatenate many of those pieces into a single string before serializing the object to XML and passing it along to something else.</p>
  
  <p>The address class is in turn part of a larger class so simply inheriting and adding this bit is more complicated were it not nested and my need isn't great enough to warrant writing a custom serializer.</p>
  
  <p>Sample:</p>
  
  <pre><code>[DataContract]
  public class Address
  {
      [DataMember()]
      public string City
  
      [DataMember()]
      public string State
  
      [DataMember()]
      public string StreetDirection
  
      [DataMember()]
      public string StreetName
  
      [DataMember()]
      public string StreetNumber
  
      [DataMember()]
      public string StreetSuffix
  
      [DataMember()]
      public string Unit
  
      [DataMember()]
      public string Zip
  
      [IgnoreDataMember()]
      [Serializable]
      public string AddressLine1
  }
  </code></pre>
  
  <p>Basically, I want to have a placeholder (AddressLine1) where I can put the concatenation of StreetXXX properties before passing along (and it's already if the receiver sees the individual pieces).</p>
  
  <p><strong>Edit - add example</strong>
  Input would be something like:</p>
  
  <pre><code>&lt;Address&gt;
    &lt;StreetNumber&gt;123&lt;/StreetNumber&gt;
    &lt;StreetDirection&gt;S.&lt;/StreetDirection&gt;
    &lt;StreetName&gt;Main&lt;/StreetName&gt;
    &lt;StreetSuffix&gt;St.&lt;/StreetSuffix&gt;
    &lt;Unit&gt;207&lt;/Unit&gt;
    &lt;City&gt;Denver&lt;/City&gt;
    &lt;State&gt;CO&lt;/State&gt;
    &lt;Zip&gt;80123&lt;/Zip&gt;
  &lt;/Address&gt;
  </code></pre>
  
  <p>But I'd want to wind up serializing to:</p>
  
  <pre><code>&lt;Address&gt;
    &lt;StreetNumber&gt;123&lt;/StreetNumber&gt;
    &lt;StreetDirection&gt;S.&lt;/StreetDirection&gt;
    &lt;StreetName&gt;Main&lt;/StreetName&gt;
    &lt;StreetSuffix&gt;St.&lt;/StreetSuffix&gt;
    &lt;Unit&gt;207&lt;/Unit&gt;
    &lt;City&gt;Denver&lt;/City&gt;
    &lt;State&gt;CO&lt;/State&gt;
    &lt;Zip&gt;80123&lt;/Zip&gt;
    &lt;AddressLine1&gt;123 S. Main St.&lt;/AddressLine1&gt;
  &lt;/Address&gt;
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>John</p>