title: How to check if T is a list of objects in a generic method
body: <p>I am trying to write a generic method for deserializing from json file(s) with Json.NET<br>
  I want to be able to support deserializing files that contain objects and also arrays of objects. Below are simplified versions of the two generic methods I have at the moment:</p>
  
  <pre><code>/// &lt;summary&gt;   Deserializes object or an array of objects from a list of files. &lt;/summary&gt;
  public static List&lt;T&gt; Deserialize&lt;T&gt;(List&lt;string&gt; filePathsList)
  {
      var result = new List&lt;T&gt;();
      foreach (var file in filePathsList)
          // HOW DO I FIND OUT IF T IS A LIST HERE?
          // Resharper says: the given expression is never of the provided type
          if (typeof(T) is List&lt;object&gt;)
          {
              var deserialized = Deserialize&lt;List&lt;T&gt;&gt;(file);
              result.AddRange(deserialized);
          }
          // Resharper says: Suspicious type check: there is not type in the solution
          // which is inherited from both 'System.Type' and 'System.Collections.IList'
          else if (typeof(T) is IList)
          {
              // deserializing json file with an array of objects
              var deserialized = Deserialize&lt;List&lt;T&gt;&gt;(file);
              result.AddRange(deserialized);
          }
          else
          {
              // deserializing a single object json file
              var deserialized = Deserialize&lt;T&gt;(file);
              result.Add(deserialized);
          }
      return result;
  }
  
  
  /// &lt;summary&gt;   Deserializes object or an array of objects from a file. &lt;/summary&gt;
  public static T Deserialize&lt;T&gt;(string filepath)
  {
      return JsonConvert.DeserializeObject&lt;T&gt;(File.ReadAllText(filepath));
  }
  </code></pre>
  
  <p>The problem is, I need to <strong>know</strong> if the T is an object or a List of objects, <strong>before</strong> deserializing. How do I check for that inside the generic method? Because resharper gives me warnings and I can't seem to figure this out.</p>
  
  <hr>
  
  <p>Edit: I made a mistake in the example code, as @Medo42 points out, it would call Deserialize() with a <code>List&lt;List&lt;Something&gt;&gt;</code>
  Also, I should not have included an example involving the json serialization at all, it should have been more generic. The question is about finding out if T is  a list of objects.</p>
  
  <p>Thanks in advance for any help.</p>