请考虑以下代码示例:
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; }
}
现在假设我在不同的地方制作了Class1的新实例,例如
var instance1 = new Class1<DataClass, long>(x => x.Data);
var instance2 = new Class1<DataClass, long>(x => x.Data);
当我这样做时,会发生什么:
答案 0 :(得分:3)