title: How do I access an object property with a string variable that has the name of that property?
body: <p>How do I do this in C#?</p>
  
  <pre><code>using System;
  
  namespace TestProperties28373
  {
      class Program
      {
          static void Main(string[] args)
          {
              Customer customer = new Customer { FirstName = "Jim", LastName = "Smith", Age = 34};
  
              Console.WriteLine(customer.FirstName);
  
              string propertyName = "FirstName";
              Console.WriteLine(customer.&amp;&amp;propertyName); //PSEUDO-CODE
  
              Console.ReadLine();
  
          }
      }
  
      class Customer
      {
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public int Age { get; set; }
      }
  }
  </code></pre>