Created
June 7, 2014 16:40
-
-
Save Fhernd/abc9295f656ccfa5576a to your computer and use it in GitHub Desktop.
Demostración del uso del método GetConstructors de 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 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