以下是我的代码,我不知道为什么 DateTime 不能更改为 Object ,有什么办法解决这个问题吗?
public class Test
{
public DateTime CreatedTime { get; set; }
}
public class Test1
{
}
public class Test2 : Test1
{
}
static void Main(string[] args)
{
Func<Test, ArgumentException> fn1 = null;
Func<Test, Exception> fn2 = fn1;// success
Func<Test, Test2> fn3 = null;
Func<Test, Test1> fn4 = fn3;//success
Func<Test, DateTime> expression1 = p => p.CreatedTime;
Func<Test, object> s = expression1; // Cannot implicitly convert type 'System.Func<IlReader.Program.Test,System.DateTime>' to 'System.Func<IlReader.Program.Test,object>'
Func<Test, ValueType> s2 = expression1; // cannot implicatily convert ....
}