【发布时间】:2011-12-28 22:45:22
【问题描述】:
我正在尝试理解 C# 中的 AST。我想知道,这个示例中的 Compile() 方法到底是做什么的。
// Some code skipped
Expression<Func<string, int, int, string>> data = Expression.Lambda<Func<string, int, int, string>>(
Expression.Call(s, typeof(string).GetMethod(“Substring”, new Type[] { typeof(int), typeof(int) }), a, b),
s, a, b
);
Func<string, int, int, string> fun = data.Compile();
为防止误解,我了解Expression.Lambda 和Expression.Call 构造。我感兴趣的是Compile() 方法。它会以某种方式产生真正的 MSIL 吗?我可以看到 MSIL 吗?
【问题讨论】:
标签: c# lambda compilation abstract-syntax-tree