<p>I want to pass in the tType of a class to a function, and the class object to a generic function.</p>

<p>I need to be able to cast to that Type (of class) so I can access the class's methods.</p>

<p>Something like:</p>

<pre><code>void GenericFunction(Object obj, Type type)
{
    (type)obj.someContainer.Add(1);
}
</code></pre>

<p>Would implementing an interface for these classes and then casting to that interface work?
If so, could someone give an example?</p>

<p>I've been Googling for the past few hours, and I've never had to do this before.</p>

<p>Can someone shed some light?</p>

Can you use generics in your method call? Something like:
```
```
void GenericFunction<T>(Object obj)
  where T : class {
  obj.someContainer.Add(1) as T;
}
```
```
Hope that helps!