title: How can I get the value of a string property via Reflection?
body: <pre><code>public class Foo
  {
     public string Bar {get; set;}
  }
  </code></pre>
  
  <p>How do I get the value of Bar, a string property, via reflection? The following code will throw an exception if the PropertyInfo type is a System.String</p>
  
  <pre><code>Foo f = new Foo();
  f.Bar = "Jon Skeet is god.";
  
  foreach(var property in f.GetType().GetProperties())
  {
   object o = property.GetValue(f,null); //throws exception TargetParameterCountException for String type
  }
  </code></pre>
  
  <p>It seems that my problem is that the property is an indexer type, with a System.String.</p>
  
  <p>Also, how do I tell if the property is an indexer?</p>