fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Mecanismo: IDisposable
  5. {
  6. public void Dispose()
  7. {
  8.  
  9. }
  10. }
  11.  
  12. public class Test
  13. {
  14. public static void Main()
  15. {
  16. Mecanismo mecanismo = new Mecanismo();
  17. Type mectype = mecanismo.GetType();
  18. var c = mectype.GetInterface("System.IDisposable"); //forma direta
  19. if (c != null)
  20. {
  21. System.Console.WriteLine("Sim");
  22. }
  23. if (mectype.GetInterfaces().Where(x => x.Name.Equals("IDisposable")).Any())
  24. {
  25. System.Console.WriteLine("Sim");
  26. }
  27. }
  28. }
Success #stdin #stdout 0.05s 34048KB
stdin
Standard input is empty
stdout
Sim
Sim