Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 7, 2014 16:40
Show Gist options
  • Save Fhernd/abc9295f656ccfa5576a to your computer and use it in GitHub Desktop.
Save Fhernd/abc9295f656ccfa5576a to your computer and use it in GitHub Desktop.
Demostración del uso del método GetConstructors de Type en C#.
using System;
using System.Reflection;
namespace Recetas.Cap03
{
public class ClaseDemo
{
public ClaseDemo () { }
public ClaseDemo (int i) { }
public ClaseDemo (int i, string s) { }
public ClaseDemo (object[] o) { }
}
public sealed class UsoGetConstructors
{
public static void Main()
{
// Arreglo de elementos `ConstructorInfo`:
ConstructorInfo[] constructores;
// Invocación de `GetConstructors` sobre la
// representación `Type` de `ClaseDemo`:
constructores = typeof(ClaseDemo).GetConstructors();
Console.WriteLine ("\nConstructores de `{0}`:\n", typeof(ClaseDemo).Name.ToString());
foreach (ConstructorInfo ctor in constructores)
{
Console.WriteLine ("\tFirma constructor: {0}", ctor.ToString());
}
Console.WriteLine ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment