Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 13, 2014 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/bf78aba8be7acd83377a to your computer and use it in GitHub Desktop.
Save Fhernd/bf78aba8be7acd83377a to your computer and use it in GitHub Desktop.
Uso de la construcción dynamic en C#.
using System;
using System.Dynamic;
namespace Recetas.Cap03
{
public sealed class PruebaDynamicObject
{
public static void Main()
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
// Genera error en tiempo de compilación:
//obj = obj + 3;
// invocación implícita del método `ToString` sobre `dyn`.
Console.WriteLine (dyn);
// Invocación de método no declarado en `dyn`,
// Generá error en tiempo de ejecución:
//dyn.MetodoInexistente();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment