title: C# Get value of a property from an object hidden behind Interface
body: <p>To explain it better, I have an object that has property of interface type that can be carrying a variety of different objects.</p>
  
  <pre><code>public class RequestParameters {
       public IRequest Request { get; set; }
  }
  </code></pre>
  
  <p>Say the interface looks something like this:</p>
  
  <pre><code>public interface IRequest {
       string Username { get; set; }
       string Password { get; set; }
  }
  </code></pre>
  
  <p>Now upon receiving the <strong>RequestParameters</strong> object, I want to get the value of a property <strong>PersonId</strong> from the object inside <strong>Request</strong> property. The interface doesn't and shouldn't contain this property, as not all of the Request types have that property. And I don't know which of the dozens of types will the <strong>Request</strong> object correspond to, so casting isn't a solution.</p>
  
  <p>So how can I possibly fetch the property <strong>PersonId</strong> in such a case? I suppose some sort of reflection is the only way, but how exactly can it be done?</p>