Execute method in C# using reflection

namespace MyCompany
{
  [TestFixture]
  public class Test
  {
    [Test]
    public void Test1()
    {
      MyClass obj = new MyClass();
 
      MethodInfo m = obj.GetType().GetMethod("Test");
      m.Invoke(obj, null);
    }
  public class MyClass
  {
    public void Test()
    {
      Console.WriteLine("Test");
    }
  }
}

Comments

Popular posts from this blog

Tibco Rendezvous (tibrv) C# .Net example

Parse XML to dynamic object in C#