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<T>()
{
Console.WriteLine(typeof(T).ToString());
}
}
it works dynamicaly and s can be of any type