Last active
August 29, 2015 14:02
-
-
Save Fhernd/0d39b1206b41f51b1474 to your computer and use it in GitHub Desktop.
Uso de dynamic para la invocación de miembros de forma dinámica en tiempo de ejecución 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.Text; | |
using System.Reflection; | |
namespace Recetas.Cap03 | |
{ | |
public sealed class VersionDynamic | |
{ | |
public void ImprimirMensaje(string param1, int param2, char param3) | |
{ | |
Console.WriteLine ("\nValores de `param1`: {0}; `param2`: {1}; `param3`: {2}", | |
param1, param2.ToString(), param3.ToString()); | |
} | |
public static void Main() | |
{ | |
// Declaración de variable `dynamic`: | |
dynamic dyn; | |
// Creación objeto `VersionDynamic`: | |
dyn = new VersionDynamic(); | |
// Invocación del método `ImprimirMensaje`: | |
dyn.ImprimirMensaje("Blog xCSw", 235, '#'); | |
Console.WriteLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment