title: How to check if a variable is an IEnumerable of some sort
body: <p>basically I'm building a very generic T4 template and one of the things I need it to do is say print <code>variable.ToString()</code>. However, I want it to evaluate lists and foreach through them and instead print <code>ListItem.ToString()</code> My T4 template does not know what type <code>variable</code> will be ahead of time, that is why this is so generic.</p>
  
  <p>But my current code that gets generated looks like this:</p>
  
  <pre><code>if(variable!=null)
    if(variable is IEnumerable) //error here
      foreach(var item in variable)
        Write(item.ToString());
  </code></pre>
  
  <p>I get a compiler error on the marked line for "Using the generic type System.Generic.Collections.IEnumerable requires one type argument" </p>
  
  <p>I don't actually care what type it is though, I just want to know if you can foreach through the variable. What code should I use instead?</p>