title: instanceof check on dynamic type
body: <p>I have the following:</p>
  
  <pre><code>interface IViewable {}
  
  class Node {}
  
  class DecisionNode : Node, IViewable {}
  </code></pre>
  
  <p>In one segment of the application, I have the following method, to which I pass an instance of DecisionNode:</p>
  
  <pre><code>void handleNode (Node node)
  {
      // ...
      var viewable = node as IViewable;
      // ...
  }
  </code></pre>
  
  <p>The problem is that this does not seem to check whether or not the dynamic/runtime type of <code>node</code> is actually a subclass of <code>IViewable</code>. It correctly rules out that this holds for the static type (<code>Node</code>), but this is not what I want to check. I get the same result if I try to cast or use <code>is</code>.</p>
  
  <p>I have been advised to use <code>GetType ().IsAssignableFrom()</code> in order to solve this, but the platform I am using (Xamarin) does not allow this. </p>
  
  <p>Is there any other way I can check if the dynamic type of my object can be treated as an instance of a given type?</p>