using System;
using System.Reflection;
namespace Recetas.Cap03
{
internal class UsoGetMethodInfo
{
public void MetodoA(int i, int j) { }
public void MetodoA(int[] i) { }
public unsafe void MetodoA(int* i) { }
public void MetodoA(ref int r) { }
public void MetodoA( int i, out int o)
{
o = 101;
}
public static void Main()
{
MethodInfo infoMetodo;
// Búsqueda del método con la firma MetodoA(int i, int j):
infoMetodo = typeof(UsoGetMethodInfo).GetMethod("MetodoA",
new Type[] {typeof(int), typeof(int) });
Console.WriteLine("\nNombre completo método: {0}", infoMetodo);
// Búsqueda del método con la firma Metodo(int[]):
infoMetodo = typeof(UsoGetMethodInfo).GetMethod("MetodoA",
new Type[] {typeof(int[])});
Console.WriteLine("\nNombre completo método: {0}", infoMetodo);
// Búsqueda método con la firma MetodoA(int*):
infoMetodo = typeof(UsoGetMethodInfo).GetMethod("MetodoA",
new Type[] { typeof(int).MakePointerType()});
Console.WriteLine("\nNombre completo método: {0}", infoMetodo);
// Búsqueda método con la firma MetodoA(ref int):
infoMetodo = typeof(UsoGetMethodInfo).GetMethod("MetodoA",
new Type[] {typeof(int).MakeByRefType()});
Console.WriteLine("\nNombre completo método: {0}", infoMetodo);
// Búsqueda método con la firma MetodoA(int, out int):
infoMetodo = typeof(UsoGetMethodInfo).GetMethod("MetodoA",
new Type[] {typeof(int), typeof(int).MakeByRefType()});
Console.WriteLine("\nNombre completo método: {0}\n", infoMetodo);
}
}
}