<p>How do I get the type of a generic typed class within the class?</p>

<p>An example:</p>

<p>I build a generic typed collection implementing <em>ICollection&lt; T></em>. Within I have methods like </p>

<pre><code>    public void Add(T item){
        ...
    }

    public void Add(IEnumerable&lt;T&gt; enumItems){
        ...
    }
</code></pre>

<p>How can I ask within the method for the given type <em>T</em>?</p>

<p>The reason for my question is: If <em>object</em> is used as <em>T</em> the collection uses Add(object item) instead of Add(IEnumerable&lt;object> enumItems) even if the parameter is IEnumerable. So in the first case it would add the whole enumerable collection as one object instead of multiple objects of the enumerable collection.</p>

<p>So i need something like </p>

<pre><code>if (T is object) {
    // Check for IEnumerable
}
</code></pre>

<p>but of course that cannot work in C#. Suggestions?</p>

<p>Thank you very much!</p>

<p>Michael</p>

You can use:
```
typeof(T)
```
```
```
if (typeof(T) == typeof(object) ) {
    // Check for IEnumerable
}
```
```