blob: 1ddabb055aefd7c38c43f910aef0b75318e92ad1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
using System;
using System.Reflection;
public class Foo<S>
{ }
public struct Bar<T>
{ }
public class Test<U>
{
public static void Func (U u)
{
Console.WriteLine (u);
}
}
class X
{
static void Test (Type t, object arg)
{
MethodInfo mi = t.GetMethod ("Func");
mi.Invoke (null, new object[] { arg });
}
public static void Main ()
{
Test (typeof (Test<Foo<int>>), new Foo<int> ());
Test (typeof (Test<Bar<int>>), new Bar<int> ());
Test (typeof (Test<Bar<string>>), new Bar<string> ());
Test (typeof (Test<Foo<DateTime>>), new Foo<DateTime> ());
Test (typeof (Test<DateTime>), DateTime.Now);
Test (typeof (Test<string>), "Hello");
}
}
|