C# Compiled lambda expressions instance creation and/or garbage collection?
问题 Consider the following code sample: using System; using System.Linq.Expressions; public class Class1<T, Y> { public Class1(Expression<Func<T, Y>> mapExpression) { GetValue = mapExpression.Compile(); } public Func<T, Y> GetValue { get; protected set; } } public class DataClass { public long Data { get; set; } } Now suppose that I make in different places new instances of Class1, e.g. var instance1 = new Class1<DataClass, long>(x => x.Data); var instance2 = new Class1<DataClass, long>(x => x