Created
October 8, 2019 21:25
-
-
Save peterthorsteinson/2fd00a3dc9248a54c5ad6e9f2826d857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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