Skip to content

Instantly share code, notes, and snippets.

@peterthorsteinson
Created October 8, 2019 21:25
Show Gist options
  • Save peterthorsteinson/2fd00a3dc9248a54c5ad6e9f2826d857 to your computer and use it in GitHub Desktop.
Save peterthorsteinson/2fd00a3dc9248a54c5ad6e9f2826d857 to your computer and use it in GitHub Desktop.
using System;
using System.Reflection;
class Program
{
static void Main()
{
Console.Write("Enter name of method to be called (Method1 or Method2): ");
string methodName = Console.ReadLine();
MethodInfo methodInfo = typeof(Program).GetMethod(methodName);
methodInfo.Invoke(null, null);
}
public static void Method1()
{
Console.Write("Method1 called!");
}
public static void Method2()
{
Console.Write("Method2 called!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment