mercredi 5 septembre 2018

how to check by reflection check if a method of a class is an implemention of his interface or not

I've the following sample :

 public interface IMyInterface {
      void MethodA();
      void MethodA(bool param 1);
      void MethodA(string param 1);
      void MethodB();
 }

 public classe MyClass : IMyInterface {
      void MethodA() {}
      void MethodA(bool param1) {}
      void MethodA(string param 1);
      void MethodB() {}
      void MethodB(int param1) {}
 }

I would check (C#) by reflection if methods declared by class "MyClass" are defined or not into the interface "MyInterface"

Expected results :

  • MyClass::MethodA() => true
  • MyClass::MethodA(bool param1) => true
  • MyClass::MethodA(string param1) => true
  • MyClass::MethodB() => false
  • MyClass::MethodB(int param1) => true




Aucun commentaire:

Enregistrer un commentaire