using System.Reflection;
namespace linqpractice
{
class MyClass
{
public static int method1()
{
return 1;
}
public static string method2()
{
return "Hello";
}
public static double method3()
{
return 1.5;
}
}
class Program
{
static void Main(string[] args)
{
Type calledType = Type.GetType("linqpractice.MyClass");
ArrayList ob = new ArrayList();
for (int i = 1; i <= 3; i++)
{
ob.Add(calledType.InvokeMember(
"method" + i.ToString(),
BindingFlags.InvokeMethod | BindingFlags.Public |
BindingFlags.Static,
null,
null,
null));
}
foreach (var item in ob)
{
Console.WriteLine(item);
}
}
}
}