title: Get only properties that implement an interface
body: <p>I have an class that implements an interface.  I'd like to examine only the property values that implement my interface. </p>
  
  <p>So, let's say for example I have this interface:</p>
  
  <pre><code>public interface IFooBar {
      string foo { get; set; }
      string bar { get; set; }
  }
  </code></pre>
  
  <p>And this class:</p>
  
  <pre><code>public class MyClass :IFooBar {
      public string foo { get; set; }
      public string bar { get; set; }
      public int MyOtherPropery1 { get; set; }
      public string MyOtherProperty2 { get; set; }
  }
  </code></pre>
  
  <p>So, I need to accomplish this, without the magic strings:</p>
  
  <pre><code>var myClassInstance = new MyClass();
  foreach (var pi in myClassInstance.GetType().GetProperties()) {
      if(pi.Name == "MyOtherPropery1" || pi.Name == "MyOtherPropery2") {
          continue; //Not interested in these property values
      }
      //We do work here with the values we want. 
  
  }
  </code></pre>
  
  <p>How can I replace this:</p>
  
  <pre><code>if(pi.Name == 'MyOtherPropery1' || pi.Name == 'MyOtherPropery2') 
  </code></pre>
  
  <p>Instead of checking to see if my property name is <code>==</code> to a magic string, I'd like to simply check to see if the property is implemented from my interface.</p>