title: Preferred way to pass a property between classes
body: <p>I have an application where I am trying to keep data access and UI separate. To that end I have two projects, one for the UI and one for data access. The problem I am having is how to efficiently pass data that is obtained from the config file in the UI project to classes in the data access project.</p>
  
  <p>The data access project contains two classes ...</p>
  
  <ol>
  <li>PaymentProcessor.cs</li>
  <li><p>Payment.cs</p>
  
  <p>The PaymentProcessor class takes care of making a Web API request to obtain a collection of "Payment" objects. I need to pass a string to the Payment object so that it can use the string to see if a specific pattern is present in the payment.</p>
  
  <p>What is the best way to pass this string into the Payment class? Do I create a property on the PaymentProcessor class and then pass as a property on the Payment class? Seems like I am playing "pass the property". Is there a better way to do this?</p></li>
  </ol>
  
  <p>Here is some sample code to show how I am using the classes and how I am passing the "ValidationString".</p>
  
  <pre><code>// Code to execute in UI
  var payProccessor = new PaymentProcessor();
  payProccessor.ValidationStringToPass = "ABCDEFG";
  payProccessor.ProcessPayment();
  
  public class PaymentProcessor()
  {
    public string ValidationStringToPass {get; set;}
  
    public void ProcessPayment()
    {
      // Get payment object collection
      List&lt;Payment&gt; paymentCollection = GetPayments();
  
      foreach(Payment p in paymentCollection)
      {
        p.ValidationString = this.ValidationStringToPass;
        p.DoStuff();
      }
    }
  }
  
  public class Payment
  {
    string ValidationString {get; set;}
  
    public void DoStuff()
    {
      // do stuff with the ValidationString
    }
  }
  </code></pre>