Skip to content

Instantly share code, notes, and snippets.

@takeshik
Created November 10, 2011 15:01
Show Gist options
  • Save takeshik/1355047 to your computer and use it in GitHub Desktop.
Save takeshik/1355047 to your computer and use it in GitHub Desktop.
var p = Expression.Parameter(typeof(int));
var expr = Expression.Lambda<Action>(
Expression.Call(
typeof(EnumerableEx),
"ForEach",
new [] { typeof(int) },
Expression.Call(
typeof(Enumerable),
"Range",
Type.EmptyTypes,
Expression.Constant(1),
Expression.Constant(12)
),
Expression.Lambda(
Expression.Call(
typeof(Console),
"WriteLine",
Type.EmptyTypes,
Expression.Constant("{0}月は Expression Trees で酒が飲める飲めるぞー!酒が飲めるぞー!"),
Expression.Convert(p, typeof(object))
),
p
)
)
);
// Run:
expr.Compile()();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment