Created
June 7, 2014 16:58
-
-
Save Fhernd/4d5591cd9ae1081a0cb3 to your computer and use it in GitHub Desktop.
Demostración uso del método GetMethods de la clase Type en C#.
This file contains 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; | |
namespace Recetas.Cap03 | |
{ | |
public class ClaseDemo | |
{ | |
public void MetodoA() {} | |
public void MetodoA(int i) {} | |
public void MetodoB() {} | |
public bool MetodoC(object[] o) | |
{ | |
return true; | |
} | |
} | |
public sealed class UsoGetMethods | |
{ | |
public static void Main() | |
{ | |
// Arreglo de elementos `MethodInfo`: | |
MethodInfo[] metodos; | |
// Obtención representación `Type` de `ClaseDemo`: | |
metodos = typeof(ClaseDemo).GetMethods(); | |
// Resultado: | |
Console.WriteLine ("Conjunto de métodos de `{0}`:\n", typeof(ClaseDemo).Name.ToString()); | |
foreach (MethodInfo metodo in metodos) | |
{ | |
Console.WriteLine ("\tFirma método: {0}", metodo.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment