I am trying to understand AST in C#. I wonder, what exactly Compile()
method from this example does.
// 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();
To prevent misunderstandings, I understand the Expression.Lambda
and Expression.Call
constructs. What interests me is the Compile()
method. Does it somehow produce real MSIL? Can I see the MSIL?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…