If it\'s harder to explain using words, let\'s look at an example I have a generic function like this
void FunctionA() where T : Form, new()
{
}
class Program
{
static void Main(string[] args)
{
int s = 38;
var t = typeof(Foo);
var m = t.GetMethod("Bar");
var g = m.MakeGenericMethod(s.GetType());
var foo = new Foo();
g.Invoke(foo, null);
Console.ReadLine();
}
}
public class Foo
{
public void Bar()
{
Console.WriteLine(typeof(T).ToString());
}
}
it works dynamicaly and s can be of any type