CSharp · Console
using System;
public class Program
{
public static void Main()
{
var classeA = new ClasseA();
var existeFuncoes = VerificaExistenciaFuncoes(classeA, "Funcao");
Console.WriteLine(existeFuncoes);
}
public static bool VerificaExistenciaFuncoes(object obj, string prefixMethod)
{
var type = obj.GetType();
bool bTodasExistem = true;
for (int i = 1; i <= 10; i++)
{
var function = type.GetMethod(prefixMethod + i);
if (function == null)
bTodasExistem = false;
}
return bTodasExistem;
}
}
public class ClasseA
{
public bool Funcao1(string a, string b)
{
return true;
}
public bool Funcao2(string a, string b)
{
return true;
}
public bool Funcao10(string a, string b)
{
return true;
}
}