title: C# Reflection PropertyInfo Nested Classes in MVC
body: <p>Is there a generic way to retrieve PropertyInfo based on a string value alone, when deeper than one level.</p>
  
  <p>I assume this is probably simple enough, but my search results are only as good as my search criteria, and I think I am having an issue articulating the proper keywords to get search results for what I am after.</p>
  
  <p>I would like to be able to do something like the following (which works perfect if the key is for a direct property / one level - ie key = 'firstName'):</p>
  
  <pre><code>public static PropertyInfo (this HtmlHelper htmlHelper, string key) {
  
       PropertyInfo pInfo = htmlHelper.ViewData.Model.GetType().GetProperty(key);
  
       return pInfo;
  }
  </code></pre>
  
  <p>But is there a way for me to return the <code>PropertyInfo</code> based on a string alone
  when Key equals something more complex, such as nested classes, objects, lists, etc...:</p>
  
  <ul>
  <li>key = "somelist[0].myproperty" </li>
  <li>key = "Items[0].someotherlist[1].someproperty" (where Items is defined as <code>List&lt;Item&gt; Items {get; set;}, someotherlist is defined similarly</code>)</li>
  </ul>
  
  <p>Can the method be generic enough to essentially drill down as many levels as needed (defined)?</p>