【发布时间】:2014-07-16 01:11:41
【问题描述】:
代码示例并不适用。它们旨在说明我尝试做我认为可能的事情的方式。
// Error: The name First does not exist...
var Contact = new
{
First = "",
Last = "",
FullName = First + " " + Last
};
// Error: Cannot assign lambda expression to anonymous type property
var Contact = new
{
First = "",
Last = "",
FullName = () => { }
};
【问题讨论】:
-
var Contact = new { FullName = (Func<string>)(() => "foo")};
标签: c# anonymous-types