var assembly = Assembly.GetExecutingAssembly();
var dinamicType = assembly.GetType("ReflectionTest.Persona");
var metods = dinamicType.GetMethods();
object obj = Activator.CreateInstance(dinamicType);
Console.WriteLine($"Getting methods from Type {dinamicType.FullName}");
foreach (var methodInfo in metods)
var parameters = methodInfo.GetParameters();
if (parameters.Length > 0)
var metodParameters = new object[1];
metodParameters[0] = "Jacopo";
var result = methodInfo.Invoke(obj, metodParameters);
Console.WriteLine($"-> method {methodInfo.Name} result in: {result}");
var result = methodInfo.Invoke(obj, null);
Console.WriteLine($"-> method {methodInfo.Name} result in: {result}");
Console.WriteLine($"-> method {methodInfo.Name} fail to execute: {ex.Message}");
[MyVersion(Version = 1, PublicName = "SayHi")]
[MyVersion(Version = 2, PublicName = "SayHi")]
[MyVersion(Version = 3, PublicName = "SayHi")]
[MyVersion(Version = 4, PublicName = "SayHi")]
public string SayHiSuper(string Who)
return $"Hello Galaxy, is this {Who}?";
public class MyVersionAttribute : Attribute
public int Version { get; set; }
public string PublicName { get; set; }