title: Checking if a generic IEnumerable is empty
body: <p>Let's say I have an object which <em>may</em> be of type <code>IEnumerable&lt;T&gt;</code>. I want to write a method that returns true if the object is of type <code>IEnumerable&lt;T&gt;</code>, is not null, and is not empty. </p>
  
  <p>Here's what I've got so far:</p>
  
  <pre><code>public bool IsNullOrEmpty(object obj)
  {
      if (obj != null)
      {
          if (obj is IEnumerable&lt;object&gt;)
          {
              return (obj as IEnumerable&lt;object&gt;).Any();
          }
      }
      return false;
  }
  </code></pre>
  
  <p>This works if I pass in an object that is of type <code>List&lt;string&gt;</code>, but not if I pass in an object that is of type <code>List&lt;int&gt;</code>. It fails because because <code>obj is IEnumerable&lt;object&gt;</code> returns <code>false</code>.</p>
  
  <p>Any idea how I can make this work for all generic <code>IEnumerable</code>s?</p>