title: How to convert object to Dictionary<TKey, TValue> in C#?
body: <p>How do I convert a dynamic object to a <code>Dictionary&lt;TKey, TValue&gt;</code> in C# What can I do?</p>
  
  <pre><code>public static void MyMethod(object obj)
  {
      if (typeof(IDictionary).IsAssignableFrom(obj.GetType()))
      {
          // My object is a dictionary, casting the object:
          // (Dictionary&lt;string, string&gt;) obj;
          // causes error ...
      }
      else
      {
          // My object is not a dictionary
      }
  }
  </code></pre>