title: Get access to value
body: <p>I have a method to call service and return a response object. I need some of data in response object. I can get access to them by having dot after response like:</p>
  
  <pre><code>  CVAResponse response = new CVAResponse();
                response = dataExchange.AddOrder(Username, Password, order);
                OrderId= response.Data;
  </code></pre>
  
  <p>There are some fields in response object that I need their value and they are not accessible using (response dot) and they are not in root of response too when I look at the response object during debug. They are inside this name space and base like:</p>
  
  <ul>
  <li><p>BookClassLibrary.DataService.CVAOrderResponse</p>
  
  <p>-base</p></li>
  </ul>
  
  <p>How I can access to that? (I tried dot after response object but there is not such a this thing)</p>
  
  <p>The CVAResponse class is written by another company and when I go to the definition that is only thing I see:</p>
  
  <pre><code>  public partial class CVAResponse : object,System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
  
      [System.NonSerializedAttribute()]
      private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
  
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private string DataField;
  
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private string ErrorMessageField;
  
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private BlueBookClassLibrary.DataExchangeService.eCVAResponseStatus StatusField;
  
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private string TicketIdField;
  
      [global::System.ComponentModel.BrowsableAttribute(false)]
      public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
          get {
              return this.extensionDataField;
          }
          set {
              this.extensionDataField = value;
          }
      }
  </code></pre>
  
  <p>Also I have this partial class:</p>
  
  <pre><code>      public partial class CVAOrderResponse : BlueBookClassLibrary.DataExchangeService.CVAResponse {
  
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private string XMLDataField;
  
      [System.Runtime.Serialization.DataMemberAttribute()]
      public string XMLData {
          get {
              return this.XMLDataField;
          }
          set {
              if ((object.ReferenceEquals(this.XMLDataField, value) != true)) {
                  this.XMLDataField = value;
                  this.RaisePropertyChanged("XMLData");
              }
          }
      }
  }
  </code></pre>
  
  <p>I need a value of XMLDataField. or XMLData.</p>
  
  <p>It can be solve by using reflection as follows:</p>
  
  <pre><code>         var properties = response2.GetType().GetProperties();
  
  
              foreach (var property in properties)
              {
                  string name = property.Name;
                  object value=  property.GetValue(response2, null);
                  if (name == "XMLData")
                      xml = value.ToString();
  
              }
  </code></pre>
  
  <p>This gava me XMLData value.</p>